How to create additional menu
Step 1 / 2
Login into administration area. Go to Developer -> Zones, press new record and fill in required information:
- name - name of menu. Choose anything you like.
- key - name of zone for use in PHP code. Typically the same name without special characters and with underscores instead of spaces.
- template - choose one of existing page layouts of current template.
- associated module group - use standard.
- associated module - use content_management.
Associated group / module - specifies module that will tell the system what are the elements of menu tree and content of each menu page. If you wish to create common text pages, leave default value standard / content_management. If you wish to represent some specific content from database, you can create your own module and specify it here (How to create your own menu module). You can leave these fields blank if you need a menu of one page. It can be useful for creating intro / splash page.
Step 2 / 2
Open your specified template layout (eg. main.php) and in desired place insert code:
<?php
require_once(LIBRARY_DIR.'php/menu/common.php'); //include menu generation class
$newMenu = new Library\Php\Menu\Common(); //create menu generation object
echo $newMenu->generate('specified_key'); //generate menu HTML
?>
This code will generate standard menu list depending on your menu tree:
<ul class="level1">
<li class="selectedSubnodes">
<a class="selectedSubnodes" title="..." href="http://...">Menu element</a>
<ul class="level2">
<li class="current">
<a class="current" title="..." href="http://...">Current page</a>
</li>
<li class="">
<a class="" title="..." href="http://...">Menu element</a>
</li>
<li class="">
<a class="" title="..." href="http://...">Menu element</a>
</li>
</ul>
</li>
<li class="subnodes">
<a class="subnodes" title="..." href="http://...">Menu element</a>
<ul class="level2">
<li class="">
<a class="" title="..." href="http://...">Menu element</a>
</li>
<li class="">
<a class="" title="..." href="http://...">Menu element</a>
</li>
<li class="">
<a class="" title="..." href="http://...">Menu element</a>
</li>
</ul>
</li>
</ul>
Use CSS to format this code to your needs.
Tags li and a may have following classes:
- subnodes - this menu element have subnodes
- current - currently selected menu element
- currentSubnodes - currently selected menu element with subnodes
- selectedSubnodes - some child of this element is selected
- typeDefault - default page type (no redirect)
- typeRedirect - this page redirects to another page
- typeInactive - without link on it
- typeSubpage - redirect to first subpage
Note
Don't forget to add few elements to this menu. To do so, go to Standard -> Menu management, select your newly created menu and press New page.
Write a comment
You must be logged in to comment.