Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Navigation showing all items in menu
    primarykey
    data
    text
    <p>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...</p> <p>As an example, using this page <a href="http://my.opera.com/spadille/blog/zend-navigation-with-xml" rel="nofollow">http://my.opera.com/spadille/blog/zend-navigation-with-xml</a> (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?</p> <p>Do I need a partial to achieve this?</p> <p>Many thanks,</p> <p>Mike</p> <p>EDIT</p> <p>Here's the XML</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;configdata&gt; &lt;nav&gt; &lt;home&gt; &lt;label&gt;Home&lt;/label&gt; &lt;controller&gt;index&lt;/controller&gt; &lt;action&gt;index&lt;/action&gt; &lt;module&gt;default&lt;/module&gt; &lt;route&gt;home&lt;/route&gt; &lt;/home&gt; &lt;admin&gt; &lt;label&gt;Admin&lt;/label&gt; &lt;controller&gt;admin&lt;/controller&gt; &lt;action&gt;index&lt;/action&gt; &lt;module&gt;default&lt;/module&gt; &lt;route&gt;admin&lt;/route&gt; &lt;/admin&gt; &lt;results&gt; &lt;label&gt;Results&lt;/label&gt; &lt;controller&gt;result&lt;/controller&gt; &lt;action&gt;index&lt;/action&gt; &lt;module&gt;default&lt;/module&gt; &lt;route&gt;results&lt;/route&gt; &lt;pages&gt; &lt;t&gt; &lt;label&gt;Charts&lt;/label&gt; &lt;controller&gt;result&lt;/controller&gt; &lt;action&gt;graph&lt;/action&gt; &lt;module&gt;default&lt;/module&gt; &lt;route&gt;charts&lt;/route&gt; &lt;/t&gt; &lt;/pages&gt; &lt;/results&gt; &lt;/nav&gt; &lt;/configdata&gt; </code></pre> <p>routes.ini</p> <pre><code> 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 </code></pre> <p>And my bootstrap</p> <pre><code> protected function _initNavigation() { $this-&gt;_bootstrap('layout'); $layout = $this-&gt;getResource('layout'); $view = $layout-&gt;getView(); $config = new Zend_Config_Xml( APPLICATION_PATH . '/configs/navigation.xml','nav'); $navigation = new Zend_Navigation($config); $view-&gt;navigation($navigation); } </code></pre> <p>And my view. I've tried...</p> <pre><code> $this-&gt;navigation()-&gt;menu() </code></pre> <p>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)</p> <pre><code> $this-&gt;navigation()-&gt;menu()-&gt;renderMenu(null,array("minDepth"=&gt;0,"maxDepth"=&gt;1,"onlyActiveBranch"=&gt;true,"renderParents"=&gt;true)) </code></pre> <p>EDIT.</p> <p>This gets me what I was after, but feels like a hack? Is this appropriate?</p> <pre><code> &lt;div class="top_menu"&gt; &lt;?php echo $this-&gt;navigation()-&gt;menu()-&gt;renderMenu(null,array("minDepth"=&gt;0,"maxDepth"=&gt;0,"onlyActiveBranch"=&gt;1,"renderParents"=&gt;true)) ?&gt; &lt;/div&gt; &lt;div class="sub_menu"&gt; &lt;?php echo $this-&gt;navigation()-&gt;menu()-&gt;renderMenu(null,array("minDepth"=&gt;1,"maxDepth"=&gt;4,"onlyActiveBranch"=&gt;true,"renderParents"=&gt;false)) ?&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload