ZF-8317: Zend_View_Helper_Navigation_Menu renderSiblings()

Issue Type: New Feature Created: 2009-11-17T00:26:04.000+0000 Last Updated: 2013-01-22T10:07:29.000+0000 Status: Closed Fix version(s): Reporter: Reko Tiira (reko_t) Assignee: Frank Brückner (frosch) Tags: - Zend_Navigation

  • Zend_View

Related issues: - ZF-6941

Attachments: - Zend_View_Helper_Navigation_Menu.patch


At the moment Zend_View_Helper_Navigation_Menu view has some shortcomings.

First of all, if you want to only render active branch, with setRenderParents(true), you can't render eg. ->minDepth(1), if the last active depth is 0; it won't find the corresponding branch to be active. This was fixed for _renderDeepestMenu couple of versions ago, but the problem still persists for _renderMenu:

<pre class="highlight">
if ($found = $this->findActive($container, $minDepth, $maxDepth)) {

The $minDepth should be $minDepth - 1 for this line, like it is in _renderDeepestMenu.

Aside from this minor bug, there's also another shortcoming with the view helper. Namely you can't render a menu such that the siblings of the active branch are also rendered. Right now you can only render the siblings of the deepest active branch.

For an example of such menu, take a look here:… It prints the active branch, but also all siblings of its parents.

I've added a new method to the view helper, called renderSiblings() (default by false to keep things backward compatible), that lets you do just this.

I know there's a similar suggestion posted here earlier (, but there are some problems with it:

  • It only checks the siblings of the deepest active branch's parent, this won't work if you render more than two depths of menu.
  • I think the name "expandBranch" is misleading and unclear. We already have renderParents(), so I think renderSiblings() is the appropriate name for this.

Included is the patch with the changes in the view helper, unit tests and documentation. Hopefully you'll consider adding it!


Posted by Reko Tiira (reko_t) on 2009-12-28T03:08:52.000+0000

Any updates on this?

Posted by Frank Brückner (frosch) on 2013-01-22T10:06:41.000+0000

I think, you can use:

<pre class="highlight">

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.