There's a telepathy module for that.
menu
Drupal Fails to Set Active Menu Trail, Causing Context to Fail
While trying to use the Context module's menu context conditions, I noticed that certain pages, though in the menu tree "Primary Links" were not properly passing the proper active menu to the context module.
Helpful: Using the Devel module's Context Inspector block to figure out if the context was failing to be called.
Bryn and I worked out that this was likely a problem with Drupal's menu system.
Helpful: Using Devel's PHP Execute block to call various menu functions from Drupal's Menu API page to inspect what the active menu trail was.
Helpful: pasting in this block of code to see what was the matter dpm(menu_get_active_trail());
We found that calling menu_set_active_menu_name('primary-links') set the active menu properly.
Now, where and how do we call that function?
Ctools uses a nice snippet that can be pasted into a helper module.
Here's what worked
//menu_set_active_menu_name($menu_name = 'primary-links');
if (menu_get_active_menu_name() == 'navigation') {
$item = menu_get_item();
$mlink = db_fetch_object(
db_query("SELECT * FROM {menu_links}
WHERE link_path = '%s'", $item['href']));
if ($mlink && isset($mlink->menu_name)) {
menu_set_active_menu_name($mlink->menu_name);
}
}
}
The module Menu Breadcrumb uses a variant of this function to unbreak the Drupal menu system.
So as an alternative to pasting this code into a module, you can try installing Menu Breadcrumb and see if your life is magically better.
Automenu.module: automatic menu parenting for Drupal 5.x
I've had a couple projects that needed the menu system to stay open when a full node was being displayed. The Drupal menu system, while dynamic and mostly awesome, didn't seem to allow for that, at least not in the way that I needed it to. So, I wrote Automenu.
For each content type, Automenu allows an administrator to set a default parent in the menu system. If a node is given an entry in the menu system, that default parent is ignored. Relatively simple.
To illustrate, let's say you'd like all nodes of type 'news' to show up under an entry in Primary links called 'Newsroom,' but you don't want to actually create an entry in the menu system for each one. Automenu will do that for you, specifically without creating additional entries in the menu system. If you want to give an individual news node its own special place in the menu system, you can still do that the standard way.
Give it a shot!
Thanks to merlinofchaos and the folks in the #drupal IRC channel for steering me in the right direction on this. They're a bunch of great and helpful folks.






