Setting all parents to "active"
dereuromark opened this issue · comments
I couldn't find anything in docs here or in issues.
Some menus require all parents to also be set "active" once a child is the "current" URI.
Otherwise, with more than 1 level, the actual current item is not visible due to the main and maybe secondary levels not being marked active and thus visible.
Is there a way to set the parents to class active once a child is found as such?
Maybe we can document this.
Side note: There is a MenuManipulator::callRecursively() method.
Would be nice to have the reverse for this on this class:
public function callRecursivelyReverse(ItemInterface $item, $method, $arguments = array())
if that helps.
The renderer has 2 options to add classes: currentClass
for the current item, and ancestorClass
for ancestors of a current item.
So your use case just means that you want to use active
for the ancestorClass
too.
The documentation should be updated to explain this.
I just stumbled upon this because I had to figure this out myself. (I read the issues afterwards)
If you read Creating Menus: The Basics its basically in the first Note:
The menu framework automatically adds
first
andlast
classes to each
<li>
tag at each level for easy styling. Notice also that acurrent
class is added to the "current" menu item by uri andcurrent_ancestor
to its ancestors (the classes are configurable) The above example assumes
the menu is being rendered on the/comments
page, making the Comments
menu the "current" item.
And the rendering options are explained some chapter below. So with some quick thinking you could get this by reading the whole basics article. While I don't see how you could improve the article itself would maybe an FAQ article be a solution with links to snippets for the solution of a question?