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.
If we use tokenised menu item as child, menu tree gets expanded on front page.
To reproduce:
1. Create node.
2. Create menu item node/1
3. Create menu item user/[user-id] that is child of menu item from #2.
4. Enable block of this menu.
5. Go to front page.
The tree node/1 -> user/[user-id] gets expanded.
Comment | File | Size | Author |
---|---|---|---|
#8 | fix_active_trail_class_in_menu_tokens_items.patch | 4.78 KB | DevElCuy |
#5 | fix_active_trail_class_in_menu_tokens_items.patch | 4.94 KB | citlacom |
#1 | menu-token-978948-custom-fake-page.patch | 3.97 KB | ygerasimov |
Comments
Comment #1
ygerasimov CreditAttribution: ygerasimov commentedI have replaced fake page to custom menu_token_landing_page. This solves the problem of active_trail and expanded menu tree. But in this way tree will never be expanded (even if we have opened page that is href of menu item that has children).
Comment #2
dealancer CreditAttribution: dealancer commentedI could not reproduce this in Drupal 7. It looks like menu never gets expended at all even for links of pages.
Comment #3
lathanI had the same issue in D7, here are the steps to reproduce
So set the
- "Source for the Main links" to main menu under /admin/structure/menu/settings
- "Source for the Secondary links" to main menu under /admin/structure/menu/settings
How to reproduce.
navigate to admin/structure/menu/settings set both primary and secondary menus to the same menu then in that menu.
- create a level 1 menu item at user/[current-user:uid]
- create a level 2 menu item childe of user/[current-user:uid] to any other page (this must be the child of the item above)
navigate to user/x and your secondary level menu items are missing.
Comment #4
sheena_d CreditAttribution: sheena_d commentedI have a customer experiencing this issue in Drupal 6. The active menu item using a menu token is receiving the "active" class on the anchor tag, but is not receiving the "active-trail" class on the list item tag.
This is causing problems with styling in the theme where styles need to be applied to the active list item or to all menu items in the active trail.
The previously submitted patch would not be an acceptable solution, because it does not allow for expanding of the menu tree and further interferes with the expected behavior of menus.
Illustration of the issue: https://skitch.com/sheenad/gyxdc/community-guidelines-realtime-reactor
Comment #5
citlacom CreditAttribution: citlacom commentedHello at BlueSpark we had a project where installed menu_tokens and experimented the problem of no active-trail class for menu items. After some dive in menu.inc code this problem is easy to explain:
The function menu_link_get_preferred($active_path, $menu_name) at menu.inc is the responsible to detect for the current request URI which menu items will be marked as active trail this is done via a query:
But the problem is that this never will return items using menu_tokens because the link_path = because we don't know the real URL so when the above query is executed doesn't retrieve any active item.
Fortunately there is a possible solution for this using a hook_preprocess_menu_link we could load the child elements for all the menu tree an iterate over the childs so doing the same verification that does the t() function to set the active class we can know if a child is active and if TRUE then set the parent as active-trail.
I attach the patch with the implementation but I only tested with a menu with 2 deep levels so is appreciated testing with deepest menus.
Comment #6
jwilson3Update version to 7.x to match patch, and marked needs review.
Comment #7
amonteroWarning:
Primary/secondary menu linking feature is not working on D7 core, altough it is still advertised in help text:
#410646: "Secondary menu" exists but is no longer the default source for the secondary links
#950034: Using the same source for main/secondary with a custom menu doesn't work
Comment #8
DevElCuy CreditAttribution: DevElCuy commentedPatch re-rolled and committed to 7.x-978948
Updated patch attached, feedback is welcome. Let's make it RTBC!
Comment #9
iLLin CreditAttribution: iLLin commentedNot sure if you are considering this the same issue. But if you have one menu with tokens and then put another menu item underneath that item with tokens, there is no active-trail applied.
Comment #10
iLLin CreditAttribution: iLLin commentedHmm, I misread post #8. He said he "committed" this and so I assumed it was committed to DEV and its not. I had to manually apply this patch to DEV and it seems to fix my issue.
Comment #11
Hydra CreditAttribution: Hydra commented@iLLin: He sayed he commited it to 7.x-978948, this is not the dev branch! You need to checkout the issue-branch manually with git, if you want to use it. It's not commited to dev yet, it's on needs-work status.
For me the patch looks good, but does not solve my issue (not related to this one sadly), so I can not really estimate, if the patch fixes the issue.
Comment #12
DevElCuy CreditAttribution: DevElCuy commented@Hydra, can you test the patch against dev?
Comment #13
cweagansI tried using the steps to reproduce in the issue summary, and applied the patch in #8, but I think the steps to reproduce might be incorrect or something, because I'm not seeing a difference. If I have time, I'll come back to this one.
Comment #14
DevElCuy CreditAttribution: DevElCuy commentedOk, this patch and issue is pretty old, and the module has changed a lot, nobody reported this bug again or I'm unable to find it, so just closing it.