I'm just not getting this; I'm using a standard XML-based Zend_Navigation impl, right out the box so-to-speak - and every page seems to have every menu option. I've tried everything - activeOnly, renderSubMenu, renderParent but they all return my either everything or nothing. I'm assuming I'm misunderstanding, because what I want (the items in the "home" node to be visible on the "home" page etc) seems to be what I would have considered the default behaviour. If I have to start setting content to "active", why do you need to specify URL or container settings in your XML - surely Zend "knows" what is active...
As an example, using this page http://my.opera.com/spadille/blog/zend-navigation-with-xml (which is very standard), I would want all the top level nodes to be visible (Home/About/Product/COntact), but only the children of the "active" page. Is that not default behaviour?
Do I need a partial to achieve this?
Many thanks,
Mike
EDIT
Here's the XML
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>default</module>
<route>home</route>
</home>
<admin>
<label>Admin</label>
<controller>admin</controller>
<action>index</action>
<module>default</module>
<route>admin</route>
</admin>
<results>
<label>Results</label>
<controller>result</controller>
<action>index</action>
<module>default</module>
<route>results</route>
<pages>
<t>
<label>Charts</label>
<controller>result</controller>
<action>graph</action>
<module>default</module>
<route>charts</route>
</t>
</pages>
</results>
</nav>
</configdata>
routes.ini
routes.home.route = "/"
routes.home.defaults.controller = index
routes.home.defaults.action = index
routes.admin.route = "/admin"
routes.admin.defaults.controller = admin
routes.admin.defaults.action = index
routes.results.route = "/results"
routes.results.defaults.controller = result
routes.results.defaults.action = index
routes.charts.route = "/results/charts"
routes.charts.defaults.controller = result
routes.charts.defaults.action = chart
And my bootstrap
protected function _initNavigation()
{
$this->_bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$config = new Zend_Config_Xml(
APPLICATION_PATH . '/configs/navigation.xml','nav');
$navigation = new Zend_Navigation($config);
$view->navigation($navigation);
}
And my view. I've tried...
$this->navigation()->menu()
and then this; The following line hides the sub items of the Results Nav, but when you click on it you only get the Item and the sub item, not the top level too (because of maxDepth)
$this->navigation()->menu()->renderMenu(null,array("minDepth"=>0,"maxDepth"=>1,"onlyActiveBranch"=>true,"renderParents"=>true))
EDIT.
This gets me what I was after, but feels like a hack? Is this appropriate?
<div class="top_menu">
<?php echo $this->navigation()->menu()->renderMenu(null,array("minDepth"=>0,"maxDepth"=>0,"onlyActiveBranch"=>1,"renderParents"=>true)) ?>
</div>
<div class="sub_menu">
<?php echo $this->navigation()->menu()->renderMenu(null,array("minDepth"=>1,"maxDepth"=>4,"onlyActiveBranch"=>true,"renderParents"=>false)) ?>
</div>