4

I have a number of navigation menus within my layout. A main menu and a sub-menu.

When clicking on an item on the main menu it shows which item is Active. When loading a page in a sub menu, the main menu loses it's context and doesn't show which item is active.

I have configured my navigation using an XML config file, and this is being read 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 generate 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 shown:

//main menu
echo $this->navigation()->menu()->renderMenu(null,array('maxDepth'   =>  0));

// ... some stuff ....

//subtree menu
echo $this->navigation()->menu()->renderMenu($this->subTree,array('maxDepth' => 0,'ulClass'=>'nav_sub'));

How do I display a submenu in my layout without the main menu losing it's context?

jjj
  • 1,136
  • 3
  • 18
  • 28
Jonny White
  • 875
  • 10
  • 21

1 Answers1

0

Try next

// main menu
echo $this->navigation()->menu()->renderMenu(null,array('maxDepth'   =>  0));

// sub menu
echo $this->navigation()->menu()->renderMenu(null,array('minDepth' => 1, 'maxDepth'   =>  1));

Both menus should have proper "active" class.

vl.lapikov
  • 756
  • 7
  • 12