ZF-8951: Zend_Navigation View Helper Menu - allow different active classes for active parents
Ideally my output navigation would look something like this:
I would like to display active parents differently from the active leaf nodes. Since I cannot use CSS markup for li.active:has(li.active) I need a different class for the parent nodes. This is a common use-case for me.
I suggest an amend to the Zend/View/Helper/Navigation/Menu.php
258 // create li element for page 259 $liCss = $page->isActive($recursive) 260 ? ' class="active"' 261 : '';
258 // create li element for page 259 $liCss = $page->isActive($recursive) 260 ? ' class="active"' 261 : ''; new // show active parent new if (!$recursive && !$page->isActive(false) && $page->isActive(true)) $liCss = ' class="active-parent"';
This will not change the current behaviour for users using setParentActive. Those not using it will get extra classes which will not affect display (unless they happen to be using that class name).
I think this is a very common use-case, so warrants inclusion in the library, rather than simply using a partial menu template.
I suspect my code could be expressed more elegantly. The option could be added as a new configuration parameter.