I have a case where nodes can be given more than one term. In this case I would like each menu item corresponding to each term to be marked as active.

Eg My terms are A,B,C and D. I have a menu with a link for each term. If I create a node and reference terms B and D, I would like the menu links for both B and D to have the 'active-trail' class.

Is this possible?

Thanks in advance.


Status:Active» Fixed


Unfortunately, it is impossible to "activate" multiple links at once on the same menu. It's a Drupal menu system limitation. But it is possible to activate one link per menu, so the only suggestion is to put term links in different menus and enable the "Separate active trail for each menu" option on Taxonomy Menu Trails configuration (on the node type settings). However, I'm not sure if this is suitable for your situation.

Thanks for the quick response. For others that might find this, I hacked my way around it by conditionally adding the 'active-trail' class to the link in a theme_preprocess_menu_link function.

Status:Fixed» Closed (fixed)

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

Hi - just wondering if you could please provide more detailed info on your workaround. I'm needing the same fax.


This is roughly what I used in my theme's template.php. Braces nesting might be a bit wonky, but you'll get the idea :

function MYTHEME_preprocess_menu_link(&$variables) {
// For the news sub-menu, nodes can be classified with multiple news categories.
  // If this is the case, each category must be given the 'active-trail' class.
if (isset($variables['element']['#original_link']['menu_name']) &&
$variables['element']['#original_link']['menu_name'] == 'menu-news-sub-menu')) {
//Check if the link is a term link
$href = explode('/', $variables['element']['#href']);
    if (
$href[0] == 'taxonomy') {
$menu_current_tid = $href[2];
      if ((
$current_node = menu_get_object('node'))) {
        if (isset(
$current_node->field_article_category)) {
          foreach (
$current_node->field_article_category['und'] as $node_term) {
            if (
$node_term['tid'] == $menu_current_tid) {
$variables['element']['#localized_options']['attributes']['class'][] = 'active-trail';
$variables['element']['#attributes']['class'][] = 'active-trail';