views:

210

answers:

3

I have a menu with two levels, the second level shown in the secondary menu.

How can I open the second menu level programmatically from pages other than those linked in the menu?

I've looked at theme_preprocess_page and others but can't figure out how the change the menu item state from collapsed to active.

+1  A: 

Could your problem be solved by just putting the items in the menu and not enabling them?

If not, you might check out the Menu Trails module, as it allows a lot more flexibility for setting active menu items.

Mike Crittenden
+1  A: 

I've been messing around with a similar issue for a while.

There's some documentation here: http://api.drupal.org/api/group/menu/6 but it's a bit sketchy on some points.

This function seems like it will do the trick: http://api.drupal.org/api/function/menu_navigation_links/6. See how you can set the level (as an argument) so the menu should render what you want.

This may not be exactly what you want but hopefully will point you in the right direction!

Rimian
A: 

Answering my own question, this node api hook does it.
Inspired by the Menu Trails module, Mike mentioned.

function phptemplate_nodeapi(&$node, $op) {
  if($open_menu_for_this_node && $op == 'view') {
    $item = menu_get_item();
    $item['href'] = $menu_item_to_open;
    menu_set_item(NULL, $item);
  }
}
Mel

related questions