Navigation Menus and Options
Controlling the level/depth of children displayed
You have control over how many levels of children (i.e. menu navigation depth) at the view level. You can use jQuery and/or CSS to accomplish this, however we believe it is always best to deliver only the necessary data using programming parameters. Here's how you can control the depth in your view/element:
- echo $nav->show('WebSection/title', $top_nav, 'menu', $data['WebPage']['section_id'], true, null, array('showhome' => true, 'type'=>'list'), null, null, 1);
Notice the last "1"? That is the depth parameter. 0 => Top-level/Section only; 1=> + Immediate Children; N => + N-related children
Only Show Children Items for Certain Sections
If you want to only show children items for a subset of menu sections, you can specify which sections will hide their children. Any section not specified will display its children based on the depth (as set in above section). To specify the sections that will not display their children, place the following code in the top-nav block settings:
- hide_pages: 1,2,3
Selecting Only Certain Sections for Navigation
There are many situations where you will only want to display a set number of "sections" in your navigation. To achive this goal, you need to setup a "Top Nav" block that specifies which sections to use in the variable settings, as a comma separated list.
Adding Classes to Navigation Items
Add the following snippet to your view/element to add classes to your nav items. The following classes will be added, where ID is the section's identity in the Database and N is the numerical index/position of the element:
- <li class="menu-title-underscored_slug_section_name menu-section-ID menu-position-N">
Adding Current Class to Sections and/or Pages
By default, the current section (depth 0) will be marked with a class="current". If you wish to change this behavior to marking the currrent page, use the following snippet:
- $nav->markCurrentPage();
Alternatively, if you wish to bread crumb the entire navigation hierarchy of the active page, basically BOTH current sections AND pages (useful for expanded accoridian menus), you need to call this function before you $nav->show() call:
- $nav->markBreadcrumbs();