The module only gives the "active-trail" class to menu items.

This way I cannot use css to style the term in which the node entry actually is. If I style the "actice-trail" class, it will work on any level of a nested term structure, to parent as to children.

This way I cannot highlight only the lowest term which is actually assigned to the node.

The solution would be to set the a tag as actice with the active class which is actually the assigned term to the node.


Dmitriy.trt’s picture

The reason I don't want to mess with additional classes, especially adding "active" class, is because:

  • The theming level is far from the module's working area.
  • It would require testing and compatibility fixes with all the ways to display the menu.
  • Adding commonly used class like "active" can really mess existing sites.

You can always use something like the following to style the deepest item: {
  /* Highlight the item. */
} {
  /* Reset styles back. */

Or modify your theme to add classes.

We could add some function with a statically cached list of selected menu items, so people could call it from the custom theme to check and add item classes. Would it be helpful? Is it really necessary?

funkytraffic’s picture

Sorry I do not see your css solution will style the deepest menu item. {
  /* Highlight any active trail item. */
} {
  /* Set anything deeper then first level */

This will highlight
- level 1 highlighted
- level 1.1 not highlighted

I need this just the opposite way ...

Dmitriy.trt’s picture

Sorry, my bad. I was hurry.

Another try: {
  /* Style for the active trail item without children */
funkytraffic’s picture

Still this will not work, if the active item has children:

- level 1
-- level 1.1 active-trail
--- level 1.1.1

level 1.1 is the term of the node/123, it will not be highlighted by this method, if not level 1 is highlighted as well.

Dmitriy.trt’s picture

OK, looks like your task can't be solved with plain CSS. You should re-implement theme_menu_link() in your theme and add some class to the item. You can get the active trail from menu_get_active_trail().

Dmitriy.trt’s picture

Status: Active » Fixed

I've reconsidered this once again and you're right. This feature will be helpful for themers and should be bundled with the module. It is committed now. Please, wait for the next dev version or checkout git. Special class "menu-item-preferred" will be added to the preferred menu item and its link. This way the risk of breaking existing websites on module upgrade will be much less and themers should be able to highlight active and non-active preferred items with different styles.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.