Issues

ZF-6978: renderSubMenu malfunctions when no submenu exists

Description

Assume you have a menu with the following tree like structure (as defined in some xml or array): * A * B ** D * C

So there are 3 root entries and entry B has D as a child entry. If the currently active menu entry is B, the following piece of code {{<?= $this->navigation()->menu()->renderSubMenu(); ?>}} will display menu entry D If the currently active menu entry is A or C, the same code will display menu entries A, B and C ( the same as you would use {{<?= $this->navigation()->menu()->setMaxDepth( 0 ); ?>}} )

In the second situation, there should be nothing displayed, because menu entries A and C don't have any child entries. This makes the navigation control unusable for displaying multiple menu levels separately.

Comments

I guess you should just use renderMenu().

Corrected some wiki markup

renderMenu() does the same thing. To obtain the same effect i would need to use: {{<? $this->navigation()->menu()->renderMenu( null, array( 'minDepth' => 0, 'maxDepth' => null,'renderParents' => false, 'onlyActiveBranch' => true ) ); ?>}} and this behaves in the same way renderSubMenu does (which may be normal because renderSubMenu calls renderMenu with these settings....as stated in the documentation).

So the fault is not with renderSubMenu only.

To complete the previous comment:

The issue was described as a renderSubMenu issue, because it refers to the type of functionality renderSubMenu represents, namely being able to render subentries of the currently active branch for a certain depth level (or an interval ... using minDepth and maxDepth). This makes possible independent renderization for each level in the menu (assume you level 1 menu is horizontal at the top of the apge, and your level 2 is vertical at the left of the page)

This is not a bug. It's the intended functionality.

I don't understand why it is intended behaviour, "'renderParents' => false", yet it renders the parents.

In the second case, A, B, and C are rendered because they are siblings of the active page.

That's incorrect, they are parents of the menu (submenu) you are displaying which has no entries.

i.e. You are rendering a menu with no items which has parents A, B & C and you declare that the parents, A, B & C not be rendered "'renderParents' => false".

A, B, and C are on the same level, level 0, thus they will all be rendered as siblings if one of them are active.

I disagree, while this might be intended behaviour it's incorrect behaviour because they are not siblings they are parents of empty menu entries (the submenu). It's very clear when you display the menu, i.e. create the menu above as one main menu with just A,B & C shown, then create a submenu which only displays the child entries of A,B &C (in a sidebar menu, the submenu of A, B or C (the parent entries)).

When you select B D will shown in the sidebar, but when select A or C A,B&C are shown when none should be because A,B & C are the parents, why should they be repeated if you declare render no parents?

If you display a main menu with a submenu and render no parents no menu item should be displayed twice.

Do you know what 'sibling' means?


         [root]
        /  |  \
       A   B   C
           |
           D

A, B and C are on the same level, they are siblings. The renderParents flag has nothing to do with it.

FYI, there have been talk about adding a renderSiblings flag. Unless someone else steps up, it probably won't be in there before zf 2.0

Yes A, B & C are siblings. B is a parent of D and D is a child of B. A & C have no children.

But assume A is active.

What should renderSubmenu() (the children) of A display?

$this->navigation()>menu()>renderMenu( null, array( 'minDepth' => 0, 'maxDepth' => null,'renderParents' => false, 'onlyActiveBranch' => true ) );

None. A has no children. A, B & C are not siblings of _none but A is the *parent* of the _none in this case.