Active menu trails set by the context module aren't respected by the nice menus module. I found this patch: http://drupal.org/files/issues/835090-4-context_reaction_menu_trail.patch which told me the right thing to do: write a ctools plugin for context that would expose a reaction for nice menus. However, I didn't do the right thing. It probably took me the same amount of time, but I went and found
- the theme function that nice menus uses to style its list items: {themename}_nice_menus_build
- the function in the context module that gives you the active contexts: context_active_contexts()
I get my active contexts inside the theme function, and set any menu reactions into $context_active_trail. Later in that function, I compare them with the menu being built:<code>
if ($context_active_trail) {
if(in_array($menu_item['link']['link_path'], $context_active_trail)){
$trail[] = $menu_item['link']['mlid'];
}
}
</code>The trail variable is used next to test the current menu item and set the active-trail class if it matches. Now Nice menus respects Context's active menu assignments. It would be nice if I went back and figured out the process to do it the right way, where the theme isn't so tightly coupled to the context module.
- the theme function that nice menus uses to style its list items: {themename}_nice_menus_build
- the function in the context module that gives you the active contexts: context_active_contexts()
I get my active contexts inside the theme function, and set any menu reactions into $context_active_trail. Later in that function, I compare them with the menu being built:<code>
if ($context_active_trail) {
if(in_array($menu_item['link']['link_path'], $context_active_trail)){
$trail[] = $menu_item['link']['mlid'];
}
}
</code>The trail variable is used next to test the current menu item and set the active-trail class if it matches. Now Nice menus respects Context's active menu assignments. It would be nice if I went back and figured out the process to do it the right way, where the theme isn't so tightly coupled to the context module.
I found another approach here: http://drupal.org/node/1331264#comment-5369002 in case you're interested.
ReplyDelete