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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Daniel Wentsch’s picture

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?

eojthebrave’s picture

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.

Daniel Wentsch’s picture

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.

jrabeemer’s picture

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".

frankcarey’s picture

+1 to getting this working

sun’s picture

Status: Active » Needs work
FileSize
1.24 KB

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.

clockwood’s picture

thanks for posting the cause of this issue. I was just about to uninstall the module and look for something else.

LaurenH’s picture

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.

jrabeemer’s picture

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. :-(

zilverdistel’s picture

Has the patch in #6 been tested yet? I ran into this issue on a production site ..

Daniel Wentsch’s picture

@zilverdistel: I'm only getting an error message telling me "The patch cannot be applied in the selected context" when trying to apply the patch from #6 on menutrails.module,v 1.4.2.24 (using Netbeans 6.9 / windows to apply patches)

Update: trying to apply the changes of patch #6 manually didn't work out for me neither. I changed $options[$data['link']['mlid']] = $title; to $options[$menu_name][$data['link']['mlid']] = $title; , as it has changed in the current version of menutrails.

The good part was that I was able to select both parent and child items inside menutrails settings but the bad part was that menutrails had no effect at all anymore, meaning activetrails were competly lost.

By the way: this patch deletes all your menutrails settings, so don't try to apply on production sites ;)

Anonymous’s picture

Facing his problem too, and it does some very odd things on multilingual sites. You get both languages mixed up in the same menu tree and you're left wondering when on earth you translated it.

Any chance of a solution here?

lucuhb’s picture

I had the same problem with 6.1.1 version : some menu items don't appear.
Like explain in #1, it seems that if several menu items lead to the same page, only the latter is displayed in the selection list of menu trails setting.

xenophyle’s picture

Version: 6.x-1.0 » 6.x-1.1
FileSize
2.15 KB

I think the problem with the previous patch is that the menu path is lost. I am attaching a similar patch. It is probably not going to be the final patch since I developed it on a system that doesn't have organic groups and may not work for OG-related breadcrumbs.
My patch modifies the option arrays for the menutrails config page by adding the mlid to the key, so the key is now in the format mlid:href instead of just href. This means that menu items with identical hrefs will now have unique keys and won't overwrite each other in the array.
When the module constructs the breadcrumb, it splits the mlid:href string and uses just the href to build the breadcrumb link.

Daniel Wentsch’s picture

Thanks for your patch (#14) xenophyle, but when trying to apply Netbeans is telling me:
"The patch cannot be applied in the selected context."

Update (1):
ok, I applied patch #14 manually. Now the menu selection in menutrails' settings is correct and shows all items in their respective hierarchy. Unfortunately the trail is still not set correctly:
According to my menutrails settings all node types "project" should show up under the menu item "Project Overview", which is a child of "Projects":
- Projects
-- Project Overview

But the active trail is being set to "Projects" only, "Project Overview" doens't get any active trail.

Update (2):
Got a workaround. In my desperation I just tried once again using menu_firstchild module - and it worked immediately! So my menu basically looks like this:
- Projects: path: [firstchild], resulting in /projects
-- Project Overview: path: /projects

So menu_firstchild generates the very same path like I set manually... but now trails are being set.
Confusing, but at least it works.

inspire-web’s picture

Hey Guys,

I am new to Drupal and doing my first project. :)
Is anyone used "Menu Trail" or "Menu Trail By Path" module ? Menu Trail was working fine for me but it stopped working when I created new menu.
I was using this http://ftp.drupal.org/files/projects/menutrails-6.x-1.1.zip on my website.

Here are my menu settings
- Primary Menu as main menu
- Sections sub nav
- Sections side nav
It was working before and I had only first two menus and when I added side nav it stopped working. I also deleted third nav but it is not working anymore.
I am not using any category to show sub sections. Should I do that? Which module will be the best in this case?
If I don't need to setup categories then what will be the best solution?
I am using PathAuto module to set SEO friendly urls and setting manually with this pattern "Primary link/Section Link/Side Nav link", also setting this link manually in the navigation to look like " Side Nav link" is under " Primary link/Section Link".

Is this ok to do ?

Thanks in advance !

Lukas von Blarer’s picture

subscribe

Lukas von Blarer’s picture

hi

@parm: were you able to solve the problem?

i have got a menu structure like this:

- menu item level 1
-- menu item level 2
--- menu item level 3

all items are linking to the same node. now, if i visit the node only the first two items are displayed. what i found out is: when i change the link of the first level menu item to something else, all level get displayed right.

menu modules i use:
- Menu block
- Menu Settings per Content Type
- Menu Trails
- Administration menu
- Auto Menu Title
- Hierarchical Select

any ideas?

thanks

lukas

glass.dimly’s picture

Workaround:

1. Disable all the child menu items or other menu items that link to paths controlled by the menu item you wish to set as active.

2. Set the menu item as active.

3. Re-enable the menu items.

4. Drink beer.

5. Repeat whenever you want to save settings for the menutrails module, or until drunk.

miguelfrias’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
FileSize
293.5 KB

It happes in drupal 7.12 too

Well I have more or less the same issue, Its seems, that the menu module, have an issue with views as frontpage. In my case, the the home and other submenu, had the class active-trail.

So What I had to do, its create the url, with a module, using hook_menu.