1

My main navigation menu is visually split as in the picture:

enter image description here

Level 1 is visualised in the upper-right corner, level 2 below.

Technology (like all the current items in level 2) is child of About.

In the screenshot, Technology has been assigned the class is-active. Is there a way to also assign it to About? In other words, I would like the entire active branch of the menu to be displayed as active.

  • 1
    If you do so it looks weird. The active link denotes the current page content. For example if the content is related to technology, you should not show active link for other menu items. That's my suggestion, if your requirements is such a way, try my answer below – Krishna Mohan Jul 18 '16 at 10:20
  • 1
    I tend to agree with you, but indeed, those are the requirements. – cornuz Jul 18 '16 at 11:49
5

You can achieve that by using the Menu Trail By Path module.

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

8.x-1.x branch

8.x-1.x branch is completely rewritten. It should be compatible with any menu.

  • I found out later that in Drupal 8 you get the active-trail class on menu-items of all levels, also without this module. I didn't see it before because I was looking for the is-active class on the menu link instead. – cornuz Jul 21 '16 at 12:23

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.