I have menu like this:
item1
- item1.1
- item 1.1.1
- item 1.1.2
- item 1.1.3
- item1.2
- item 1.2.1
- item 1.2.2
item2
- item2.1
- item2.2
I set `setOnlyActiveBranch(true); And if I choose item.1.1.1 or item.1.1 I get this one:
item1
- item1.1
- item 1.1.1
- item 1.1.2
- item 1.1.3
At the same time if I press item1 I got this one:
item1
- item1.1
- item1.2
I don't want to hide other root nodes if the current node is active. So how to show menu this way (in case I choose item1.1. for example)?:
item1
- item1.1开发者_C百科
- item 1.1.1
- item 1.1.2
- item 1.1.3
- item1.2
item2
Is it possible to to it via standart methods or should I create new helper?
{get|set}RenderParents() gets/sets a flag specifying whether parents should be rendered when only rendering active branch of a container. If set to FALSE, only the deepest active menu will be rendered.
http://framework.zend.com/manual/en/zend.view.helpers.html
This is not possible with the standard methods of the navigation view helper, which is unfortunate, because it is a common case.
However there are some case issues that the ZF developers should have in mind, probably that is why it is not implemented. Such case is if you want to show non-active branches to the second level.
Item 1 - active
Item 1.1 - active
Item 1.1.1 - active
Item 1.1.2
Item 1.2
Item 2
Item 2.1
Item 2.2
You may also wish to have other case, show only main items, and only the active branch.
Item 1 - active
Item 1.1 - active
Item 1.1.1 - active
Item 1.1.2
Item 2
I had that solved with rendering the whole menu and hiding the non-active branches with CSS.
But you may wish to limit your markup so you have to make your custom renderer.
精彩评论