It would be nice if one could lock "Local Menu" to one particular menu, instead of always displaying the currently active menu. For my site, it should only display the second level of my main navigation menu and not the administration menu, because this menu is a different kind of menu and displayed in a different place. If the administration menu is active, the Local menu part should just be blank.

For my small site, I just hardcoded the menu into the module which works well enough for me. But maybe this issue is also important for other users of the module.

Comments

ztyx’s picture

Subscribe

grendzy’s picture

I'm been trying to do this as well. The difficulty is I can't find a way to get the current root menu. There is menu_get_active_trail(), but that doesn't include the menu name (e.g. 'primary-links'). Oddly, this used to work in Drupal 5.

There's also menu_get_active_menu_name(), but it always (incorrectly IMO) returns 'navigation'. I looked at the code and it seems like this API function was essentially left unimplemented -- it's never set anywhere (except the book module).

I have found a workaround for my current situation. I'm using the trick where the primary / secondary links are pulled from the same menu, and I want the secondary links displayed as a block.

I put this in the block visibility settings for the local_menu block:

// Only show this if there are secondary links, to prevent it from being displayed in admin menu etc
if (sizeof(menu_secondary_links()) > 0) {
  return true;
} else {
  return false;
}
Andreas Schmidt’s picture

There is an easy way of hiding this block on admin-pages:

Edit the local-menu-block and insert "admin" and "admin/*" to "Page specific visibility settings". Choose the first radio-button and it won't display the local menu twice on admin pages.

ztyx’s picture

Have a look at #296558: Default menu option when item in multiple blocks which looks like an alternative solution.

akalsey’s picture

Status: Active » Closed (duplicate)

There's a patch in #296558: Default menu option when item in multiple blocks that allows you to choose which menu to show if an item is in multiple menus.