I have posted some images to best illustrate the problem.

For a system menu block, if you create a menu item with children, they will expand if you visit them. This is illustrated in the first screen shot, where you can see that that Node 6 is child of Node 5 which is child of node 4. This can be seen both in the menu and in the breadcrumb.

The 2nd image shows the problem. I'm in the same situation as before only with the node names being 3, 2 and 1. This time, however, there is no breadcrumb and the menu items hasn't expanded.

With a quick hack, I'm able to get the desired result, which is shown in the 3rd image.

I'm not well versed in the menu system, but I believed I have tracked down the root of this. The problem is located in

menu_link_get_preferred

Which attempts to find a menu link for a path, it does this by querying the active menus gotten like this:

// Retrieve a list of menu names, ordered by preference.
$menu_names = menu_get_active_menu_names();

The problem with this, is that this isn't actually the active menus that it's getting, it will instead return this:

variable_get('menu_default_active_menus', array_keys(menu_list_system_menus()));

Now getting the active menus through a variable_get is not so bad in itself. I would have preferred Drupal figuring out what menus is active. The only thing is, that is variable can't actually be set through the interface anywhere. This means, that if you want to have menu with children that should expand and have breadcrumbs, you need to either create a custom module, that will allow you to configure the active menus and remember to keep this up to date, or hardcode the active menus in the settings.php file.

I don't really like any of those approaches and for any one to actually be able to do this, they need to know the name of the variable which wasn't that easy to attain.

I'm not sure what the best way would be to fix this issue. A solution could be to get the menu links from all menus, and try to make the best guess if multiple menu items are present. The problem is in reality that there isn't an easy way to figure out which menus are active.

At the very least, we should make an interface interface to select the active menus and add newly created menus to this list.

CommentFileSizeAuthor
desired.png28.38 KBgoogletorp
default.png24.83 KBgoogletorp
system_block.png28.82 KBgoogletorp

Comments

googletorp’s picture

Looking at how this was done in Drupal 6, it looks like that menu name for the menu that was being built was used when querying the database for available items. It could also be a solution to allow menu_link_get_preferred to receive a menu name to add to the default list of active menus.

That should fix the problem of menu's not being built, but might cause trouble if the same link is present in more than one menu. In this case it should be possible to let it default to one of the possibilities allowing for one of the menus to be expanded and create a breadcrumb based on that.

mikl’s picture

Yeah, this is a nasty gotcha, we wasted lot of time poking around to figure this out…

amanaplan’s picture

subscribing

amanaplan’s picture

david lesieur’s picture

Status: Active » Closed (duplicate)
trinin’s picture

subscribing