2

I have a system of menus on a site that helps the user drill down to the page they are looking for. If they click a link in the main nav, it might take the to /category. On that page, a sidebar menu would direct them to /category/page.

Previously, I have used the active class to highlight a menu item while the user is on that page. In this case, I want both menu items to be highlighted, since the page the user is on falls is a part of the main category.

To clarify, how can I keep a link active if it points to /category and the page the user is viewing is /category/page?

Thanks for the help!

1

There is a module for that - Menu Trail By Path

Menu Trail By Path sets the active-trail on menu items according to the current url.

For example if you are at yoursite.com/blog/category1/article1

Menu Items with these paths will get the active-trail class on them and expand accordingly.

blog
blog/category1
blog/category1/article1

This is particularly useful if you want a lot of nodes to appear as children of certain nodes / taxonomy term / views / referenced nodes / etc, but do not want to add them all to the menu. eg. hundreds of blog articles.

Menu Trail By Path is best used in conjunction with Pathauto.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.