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.
Hey!
On a D7-page I have a menu at the top that only contains the root elements of the specified menu. The other items of this menu - depending on the chosen topmenu-link - will be displayed on the left site via menu_blocks module. No problem so far.
But I need to style the menu on the left depending on the associated root-menu-item. So I need to have someting like the mid of the active menu root item in the menu's classes. Is there any way to do this?
Comment | File | Size | Author |
---|---|---|---|
#5 | 0001-implemented-1060142-Make-Active-Parent-menu-ID-avail.patch | 2.57 KB | geek-merlin |
Comments
Comment #1
Zuzuesque CreditAttribution: Zuzuesque commentedHey,
I have the very same problem. For a theme I am working on I have a horizontal main menu and a vertical submenu. Depending on what item was selected in the main menu I want to set the submenu's background color - so I would need the name or id of the parent element added to the child's class list.
The stange thing is - it seems a menu item does already give out the parent-mlid - sadly it is always 0, no matter what the mlid of the parent element is. I am not sure but I feel this is a bug. Some help on this issue would be greatly appreciated.
Comment #2
JustMagicMaria CreditAttribution: JustMagicMaria commentedI could really use this too. Since the parent-mlid is always 0, I'm switching the category of this issue to bug report.
Comment #3
Zuzuesque CreditAttribution: Zuzuesque commentedChecking other issues, it seems to be the same bug someone already made a patch for: http://drupal.org/node/1209520
Comment #4
geek-merlinad #3: no, this is not a dup of #1209520: Parent menu item not set/retrieved correctly.
Comment #5
geek-merlinyay, and here's the fix to make our themers happy:
the menu wrapper now gets a css class like 'active-parent-mlid-1234'.
i intentionally named the class different than the 'parent-mlid-1234' class because this is for menus with fixed parent, and this is about a menu with fixed level.
(coders, i'm not too proud passing the new info in the config array but it seems the only way without creating globals or making bigger data model changes.)
Comment #6
JohnAlbinTHis is a feature request not a bug. And I'm not terribly excited about adding it. It's an edge case.