I needed the ability to assign node types to menu items within more than one menu, but the current version of this module only allows you to use one menu.

The following patch allows you to choose a parent menu item from any of the menus configured on your site.

Steps to test:

1. Install menutrails.module 6.x.1.x-dev and apply the attached patch.
2. Navigate to admin/build/menu/trails, open one of the fieldsets and then click one of the select menus. You should see all the menus on your site, not just primary-links. Choosing any of these items should have the same results as the module previously did. When the appropriate conditions are met your node should display as a child of the selected menu item.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

roborn’s picture

Status: Needs review » Reviewed & tested by the community

Works great.
Tkxs! :)

sun’s picture

Status: Reviewed & tested by the community » Needs review

Hmmm... Don't we rely on a single menu elsewhere in the module?

marcushenningsen’s picture

It works for me, too. Thanks for this feature, it should make its way into stable.

spelcheck’s picture

First off, thank you eojthebrave for the patch.. it's exactly what I'm looking for, just needs a little help.

Using this patch, when I select a menu item from let's say Secondary Links that shares the same link as a menu item within Primary Links, it will default to the Primary Links menu item once saved and will active-trail the menu items within both menus. Further, if there are multiple links within Primary Links that share the same link (node/#) as the selected menu item within the Secondary Menu, it will default to the oldest created menu item that shares the same link. Example:

Primary Links
- a link I created two days ago
- a link I created a day ago
- a link I created just now

Secondary Links
- the only link I wanted to active-trail

Let's imagine all of these links have the same link (node/123) When "the only link I wanted to active-trail" is selected for a node-type and Menu Trails is saved, once reloaded it will have defaulted to "a link I created two days ago." If you then browsed to a page with that specific node-type, Menu Trails has active-trailed both "a link I created two days ago" and "the only link I wanted to active-trail"

I haven't gone under the hood and played with the .module but figured I'd get this out there so nobody gets too excited and pulls the trigger to have it committed to stable. More notes: I tried setting different "Menutrails Menu:" from within the Menu Trails main screen with no changes. I deleted "a link I created two days ago" and it predictably fell back to "a link I created a day ago" regardless of it's location or weight within the menu. I have tried renaming Secondary Links to ZSecondary Links just to make sure precedence wasn't based on Menu Name. Before patching, I wouldn't have the option of active-trailing multiple menus, so two steps forward, one step back! Thanks everybody who contribute, hope to help tomorrow on this issue.

eojthebrave’s picture

I could be wrong, but if I am interpreting this correctly I think you are experiencing this issue. #440578: Selection of some menu items is not possible/available

The patch in this thread makes all the menu items in your secondary links menu available, but if they share the same URL as a link in your main menu you're likely going to run into the issue mentioned there.

spelcheck’s picture

I'm desperately fighting the urge to wipe my last post.. oh well, for the good of the thread I suppose. Thank you for the help! Yes, that definitely looks like the 'bug' I'm running into. I'd like to think that if I had another hour to spend on this last night, I would have flagged the 'if ($menu_item['link']['link_path'] == $item['href'])' line and had something constructive to add this morning. I am still a little bit confused though. With both patches applied, what does the selection in 'Menutrails Menu:' affect? The original help text says 'This menu will be used if there is ambiguity about what menu a node falls under.' but since we're being very specific about which menu we're using and even further, we're being specific about which mlid we're using.. is there any ambiguity? Thanks again!

sun’s picture

@eojthebrave: Can you reply to my concern in #2, please?

eojthebrave’s picture

@sun: as far as I understand it we don't not rely on a the use of a single menu anywhere else in the module. The only other place that this line of code is used $menu = variable_get('menutrails_menu', 'primary-links'); is in the function menutrails_get_breadcrumbs() where it is only being used as a preference allowing the admin to assign the default menu that is used, falling back on a query to the menu_links table to find the necessary $menu if none is set in the above preference.

For what it is worth, I have been using this module with the above patch applied for months on at least 10 different sites with no issues.

This functionality also existed/exists in the Drupal 5 version of the module where it worked fine as well.

zoo33’s picture

Status: Needs review » Reviewed & tested by the community

The variable menutrails_menu appears in three places in the module:

grep "variable_get('menutrails_menu'" menutrails.module 
    $menu = variable_get('menutrails_menu', FALSE);
  $menu = variable_get('menutrails_menu', 'primary-links');
    '#default_value' => variable_get('menutrails_menu', 'primary-links'),

I believe the two of them that are not touched by this patch deal with choosing the default menu tree for paths that have multiple menu links, like eojthebrave says.

The patch seems straightforward. I've tested it and it seems to work like it should. However, it didn't apply to my 6.x-1.0 version, but it's easy enough to apply it manually.

By a coincidence I discovered one minor flaw though: If you have two menu items in two different menu trees, pointing to the same href, you won't be able to choose the menu item in the tree that is not chosen as the default. In other words, it will always change your preference to the corresponding link in the default tree, if the link you choose also appears in that tree. Wow, is that readable at all?

I'm prepared to leave that issue aside for now and boldly call this RTBC. (I need this myself and I'd like to not have to apply the patch next time I update the module...) Thx!

eojthebrave’s picture

@zoo33, FYI there is already an issue open for the multiple menu items with the same href bug. #440578: Selection of some menu items is not possible/available

sun’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
1.45 KB

Thanks for reporting, reviewing, and testing! Committed attached patch.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

sun’s picture

However, I could need some help in #475684: Menutrails assignment fails if menu item is in any menu, which seems to have to be reworked due to this patch now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.