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 you have two menu links going to the same page, menu hierarchy should use the minimum-depth one to get the parent menu link.
That's what it does for menu links having parents, but if a menu link has no parent (top-level), it's not taken into account.
Here's a patch to fix this.
Comment | File | Size | Author |
---|---|---|---|
#2 | crumbs-7.x-2.x-2527570-menu-toplevel.patch | 2.2 KB | donquixote |
menu-hierarchy-prefer-top-links.patch | 1.43 KB | GaëlG | |
Comments
Comment #1
donquixote CreditAttribution: donquixote as a volunteer commentedHi,
I am not completely sure and convinced that the solution correctly covers all use cases.
Some cases to consider:
One possible solution here could be to have a separate plugin for toplevel items, which can be separately prioritized.
Yes, this does add complexity, so maybe we should do this in 7.x-3.x, where the prioritization UI looks cleaner.
Comment #2
donquixote CreditAttribution: donquixote as a volunteer commentedWhat about this?
It returns NULL for those menus where the child is a toplevel item.
It uses "LEFT JOIN" so we don't need the separate query.
Comment #3
donquixote CreditAttribution: donquixote as a volunteer commentedThis means:
- If a path appears more than once in a menu, and one of these is a toplevel item, then no parent candidate is returned for this menu, and other plugins can do their thing.
- If a path is a toplevel item in menu A, but a deeper item in menu B, then the parent from menu B will be used.
- If a path is a deeper item in menus A and B, and A is first in the priority list, then the parent from menu A will be used.
Maybe we could have a page where you can configure a "root item" for each menu (which would default to the frontpage).
Or we could assume that the toplevel item with smallest weight in each menu is the root item?
Comment #5
donquixote CreditAttribution: donquixote as a volunteer commentedThe commit fb599bb implements the behavior outlined in #3.
This means we do *not* imply that the frontpage is the correct parent for each toplevel item. Instead we give other plugins a chance.
This would have to be a follow-up.
Also notice the commit before this, 308a725, which changes the implementation of Special menu items with
<nolink>
, and removes the separate plugin.