Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am using Menu token to have a contextual menu with links such as [node:url]/news. This menu will replace the $main_menu, whenever the content type is an OG group. The link will then open a page (created with page manager as node/%node, with the selection rules: OG content type and path */news (Sub-Pathauto))
This all works fine but the link does not get the active trail. I tried various modules to set the active trail by url or what so ever, but they were not working with token links from the menu.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2063113-menu_token_active_trail-7.patch | 2.38 KB | mariancalinro |
Comments
Comment #1
DevElCuy CreditAttribution: DevElCuy commented@MarMax, thanks for your feedback! This feature is a must.
If somebody wants to make Menu Token a LOT better, please send a path for this issue.
Comment #2
MarMax CreditAttribution: MarMax commented@develCuy, very welcome. This request would improve Menu Token really a lot.
Otherwise I really don't understand, how Drupal developers make a contextual menu work properly. The active-trail is essential. Is this functionality just not implememted yet or is it the way I am using it, which causes this issue?
Comment #3
dlthomas CreditAttribution: dlthomas commentedI also have this issue when I use [node:url]. Unfortunately the menu links are also not distinct in any way with regards to the classes. I'm going to try using javascript for now until the issue is resolved.
Originally I used 'content/[node:id]/[node:title]/keyword', but the menu wasn't showing on some pages. The active trail did work when I used those tokens however so I believe it works depending on what tokens you use.
Does anybody know why this is happening?
Comment #4
Exploratus CreditAttribution: Exploratus commentedNeed active trail. It's critical.
Comment #5
david.lopez CreditAttribution: david.lopez commentedQuick, completely dirty and not-in-deep-tested "fix"
Line 153 of menu_token.module, add this.
Comment #6
mibfire CreditAttribution: mibfire commentedThe fix should be this:
Line 153 of menu_token.module
But it doesnt work either.
Comment #7
mariancalinro CreditAttribution: mariancalinro commentedI've encountered this also, and followed it to the function menu_link_get_preferred(), where the preferred link is loaded when calculating the active trail. This function queries the database, but can't find the resolved path there, as the links are stored in the following format: 'menutoken/%'.
To work around this, I alter the query, and changed the condition to match on the corresponding 'menutoken/%' path, if found.
Also, for menu_link_get_preferred() to match the result, I modified the field link_path to an expression returning the resolved path as a static string.
I am not happy that I have to hit the db a few extra times per page load, but I couldn't see any noticeable performance hit.
Please use the patch if you have the need for the active trail to work, and let me know if there's any problem you encounter.
As a note, I am using this patch on a live website.
Comment #8
DevElCuy CreditAttribution: DevElCuy commentedI'm eager to commit the patch! Can somebody help with testing?
Comment #9
DevElCuy CreditAttribution: DevElCuy at Dilygent commentedAfter a year, nobody tested the patch, that is disappointing. Do you really want this new feature in? please help testing :)
Comment #10
bmango CreditAttribution: bmango commentedI am interested in seeing this new feature added to the module.
I applied the patch and it applied cleanly. However it did not add in the active trail classes to a menu link using tokens. It didn't appear to make any difference at all :(
Comment #11
reszliIt worked fine for me when using a node/[token]/edit link in a menu.
@bmango, can you give an example you were using and it did not worked?
if not, this could go to RTBC from my point of view
Comment #12
bmango CreditAttribution: bmango commented@reszli - I don't think I still have the site set up I was using to test it on and it is quite possible I had not tested it correctly so I think it is fine to set this to RTBC
Comment #13
DevElCuy CreditAttribution: DevElCuy at Dilygent commentedThanks @bmango and @reszli! Please go mark this issue RTBC, it doesn't bites ;)
Comment #14
bmango CreditAttribution: bmango commentedUpdated :)
Comment #16
DevElCuy CreditAttribution: DevElCuy at Dilygent commentedThanks everyone for making this possible! Great team work :D