There are several navigation menus in my layout. Main menu and submenu.
When you click on an item in the main menu, it shows which item is active. When loading a page in a submenu, the main menu loses context and does not show which element is active.
I customized my navigation using the XML configuration file and it reads in my Bootstrap.php
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'home');
$navContainer = new Zend_Navigation($navContainerConfig);
$this->view->navigation($navContainer);
$layout = $this->bootstrap('layout')->getResource('layout');
$layout->getView()->navigation($navContainer);
Then in my controller, I create a subtree menu:
$subTree = $this->view->navigation()->findOneById('settings_index');
$this->view->subTree = $subTree;
In my layout, I have the main nav, and the subtree is shown:
echo $this->navigation()->menu()->renderMenu(null,array('maxDepth' => 0));
echo $this->navigation()->menu()->renderMenu($this->subTree,array('maxDepth' => 0,'ulClass'=>'nav_sub'));
How to display a submenu in my layout without the main menu losing its context?
source
share