Zend Framework - Multiplate Navigation Blocks

Zend Framework - multiplate navigation blocks

I have had this exact same issue. I just create multiple instances of Zend_Navigation_Container in my controllers for each of the menus I need, pass them to the view and then render them by passing the objects directly to the menu render method. As follows:

In the controller:

$this->view->menu1 = new Zend_Navigation_Container();
$this->view->menu2 = new Zend_Navigation_Container();

In the view:

$this->navigation()->menu()->renderMenu($this->menu1);
$this->navigation()->menu()->renderMenu($this->menu2);

You could even customise each one (by inserting method calls after the initial menu() call:

$this->navigation()->menu()->setUlClass('my_first_menu')->renderMenu($this->menu1);
$this->navigation()->menu()->setUlClass('my_second_menu')->renderMenu($this->menu2);

Zend_Navigation: Having trouble getting breadcrumbs to render using multiple containers

This is probably a dirty solution, but I manually set the container reference using Zend_Registry like so:

Zend_Registry::set( 'nav' . $menu, $container );

And spit it out like so:

$main = Zend_Registry::get( 'nav' . $this->mainMenuId );
echo $this->navigation( $main )->breadcrumbs()->setMinDepth(0);

Zend Navigation - various navigation blocks

findOneByLabel('acc_nav'); will search for text in <label>-tags as there is nog acc_nav value. It won't find it.

Different Navigation Menus for Controller Views - Zend Framework

Personnaly, my navigation menu is stored in an XML file. When I create my "Zend_Navigation", I load only on part of my navigation menu like this :

$navigation = new Zend_Navigation(new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', $controllerName));
$view->navigation($navigation);

Where "$controllerName" is a section of my "navigation.xml".

In your view:

<?php echo $this->navigation()->menu()->renderMenu(); ?>

Enjoy

Zend Framework: Navigation XML and duplicate page elements

You can't use the first XML structure, because Zend_Navigation uses the Tag definition to create a part of the "Route". If you want use an another type of XML structure, you probably have to extend Zend_Navigation with your own parsing process.

$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml');
$container new My_Navigation($config);

Another way would be to create a class to parse and modify the XML document before sending it to Zend_Navigation.

$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml');
$navigationStructure = new My_Navigation_Parser($config);
$container new My_Navigation($navigationStructure);


Related Topics



Leave a reply



Submit