Display only part of the Zend_Navigation object in the menu

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:

//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 to display a submenu in my layout without the main menu losing its context?

+4
source share
1 answer

Try the following

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

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

"" .

0

Source: https://habr.com/ru/post/1614945/


All Articles