Selection of some menu items is not possible/available
| Project: | Menu Trails |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Hi everybody and thanks for your great module. I've been using it successfully on another site, but on my current project I'm experiencing a problem.
I need to set menu trails based on categories. The two attached screenshots will explain my problem probably best, but I try to write it down, too.
I have my main menu ("Hauptmenue" on my screenshots) set up as primary-links and also set this menue as my base inside menu_trails config.
Now I want to assign each taxonomy term of a vocabulary called "kunde" (meaning "client") a different parent menu item. This parent item should be a second level menu item of my main menu. But the select field inside the menu_trails config simply doesn't show me the entire menu tree to select the correct items. (as shown on the second screenshot).
I tried adding new menu items under the main menu and they didn't show up in the select box neither.
I haven't found a similar issue here - has somebody eventually experienced the same problem and can point me in the right direction?
Thanks and regards,
Daniel
| Attachment | Size |
|---|---|
| Settings of my menu | 15.46 KB |
| Settings of menu_trails | 27.14 KB |

#1
Okay, I now tried manually rebuilding the same menu structure as a new menu and it seems to work.
Could it be a problem that some of my menu items are set automatically via views?
//edit: hm. I was wrong. Still doesn't work as it should. As soon as I added some more menu items and nested them, the ones on the first level are not selectable in menu trails administration :(
Update: found the root of the problem!
My menu has items that link to the same path, e.g. the first item on the second level points to the same view as the item on the first level:
-- item 1 //--> links to view/1 and does not appear in menu trails administration---- item 1.1 //--> links also to view/1 and _does_ appear in menu trails administration
---- item 1.2 //--> links to view/x and also does appear in menu trails administration
It seems that if two or more menu items link to the same node or view only the last one will be selectable in menu trails administration. I tried appending (useless) parameters to the pathes and as soon as the path wasn't the exact same, both menu items became selectable in menu trails.
I don't think this is intended, is it? Any idea to fix it?
#2
It looks like the problem is line 385, with the _menutrails_parents_recurse function.
$options[$data['link']['href']] = $title;When building the options array that will eventually be used in the form select element where you can choose which menu item should act as a parent the array is using the $data['link']['href'] as a key, and then eventually storing that key and using it to lookup the appropriate parent for a node later on. If however you have more than one menu item that points to the same path, ie.) 'view/1' every time the loop comes across a menu item with that path it will overwrite the existing data in the $options array and you'll always end up with only the last/heaviest menu item with the path 'view/1' in your select menu.
I think the thing to do would be to use the $data['link']['mlid'] value as the $options array key since that should be unique. The mlid value should be stored in the database, and then he menutrail_nodeapi operations should perform lookups based on the menu.id (mlid) instead of the href/path value.
#3
Thanks a lot for explaining.
In the meantime I built my menus differently (for other reasons, too), which had the nice side-effect of not having menu items linking to the same paths.
#4
Can we put a notice in the help text? I ran into this "bug". In my case, I have menus with "node" paths that don't go anywhere as a temporary placeholder. All I see in the node list is one menu item, the last one, of which they all have the same path.
Amended:
It seems to show non-system menu paths other than, "node".
#5
+1 to getting this working
#6
Kick-start. Not sure whether this works and can be changed that easily (untested). If it does, we need a module update that transforms the old settings into the new.
Downside of this approach is that mlids can change more often than you want to/thought of. hrefs can, too, but are more reliable in general.
Anyway, I agree this is a problem we need to fix.
#7
thanks for posting the cause of this issue. I was just about to uninstall the module and look for something else.
#8
Yeah this was not the expected behavior at all. I'm using Menu Firstchild for a handful of my links, and Menu Trails treating these as the same menu item is very confusing.
#9
I believe #1 is correct. I think it's picking the last menu that has the same identical link. In any case, DON'T USE THE SAME MENU paths!
If you have a top level menu in Primary Links
eg. The following will cause 1. "About Us" at the top root level to NOT appear in the menu trails drop down. It just disappears.
Primary Links:
1. About Us (linked to-> about-us/mission) (DOES NOT APPEAR in menutrails drop-down)
1.1 Staff (about-us/staff)
1.2 Mission (about-us/mission)
1.3 Contact (about-us/contact)
1.4 People (about-us/mission) (May or may not appear in menutrails drop-down. It's inconsistent what menutrails does here)
2. XXXX
2.1 XXXX
3. etc..
In any case, menutrails is starting to bitrot.. One year of no stable release since Oct '08. :-(