--- old/context_menu_block.module 2014-03-14 17:03:41.000000000 +0100 +++ new/context_menu_block.module 2015-01-15 16:23:56.116004300 +0100 @@ -123,28 +123,32 @@ function context_menu_tree_add_active_path(&$tree, $active_paths) { foreach (array_keys($tree) as $key) { - if (!empty($tree[$key]['link']['href']) && in_array($tree[$key]['link']['href'], $active_paths)) { - // Set the active trail. - $tree[$key]['link']['in_active_trail'] = TRUE; + foreach($active_paths as $active_path) { + if (!empty($tree[$key]['link']['href']) && + in_array($tree[$key]['link']['menu_name'] . ":" . $tree[$key]['link']['href'], $active_path) && + !$tree[$key]['link']['hidden']) { + // Set the active trail. + $tree[$key]['link']['in_active_trail'] = TRUE; + + // The Drupal Way is to only set the active menu when the page is actually + // the active page. However, the context reaction is supposed to set the + // active menu. So, we need to "fake" the active menu by styling the link + // as active. + $tree[$key]['link']['localized_options']['attributes']['class'][] = 'active'; + + // Found a match, so break the recursion. + return TRUE; + } + elseif (!empty($tree[$key]['below'])) { + // Check the child menu to see if the active path can be matched. + $tree[$key]['link']['in_active_trail'] = context_menu_tree_add_active_path($tree[$key]['below'], $active_paths); - // The Drupal Way is to only set the active menu when the page is actually - // the active page. However, the context reaction is supposed to set the - // active menu. So, we need to "fake" the active menu by styling the link - // as active. - $tree[$key]['link']['localized_options']['attributes']['class'][] = 'active'; - - // Found a match, so break the recursion. - return TRUE; - } - elseif (!empty($tree[$key]['below'])) { - // Check the child menu to see if the active path can be matched. - $tree[$key]['link']['in_active_trail'] = context_menu_tree_add_active_path($tree[$key]['below'], $active_paths); - - // If a match has been found, break the recursion. - if ($tree[$key]['link']['in_active_trail']) { - return TRUE; - } - } + // If a match has been found, break the recursion. + if ($tree[$key]['link']['in_active_trail']) { + return TRUE; + } + } + } } // If we didn't find an active item, return FALSE.