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.
Please, add the possibility to include vocabulary terms into submenu for any existing menu item.
For example I have Main menu like this:
-News
-Videos
-Pics
I have vocabulary 'Video' with terms: Animals, Kids, Vines. Needs to include these terms into the Main menu like this:
-News
-Videos
---Animals
---Kids
---Vines
-Pics
Comment | File | Size | Author |
---|---|---|---|
#24 | submenu_into_existing-2723807-24.patch | 5.67 KB | dstol |
| |||
#22 | submenu_into_existing-2723807-22.patch | 5.65 KB | dstol |
#20 | submenu_into_existing-2723807-20.patch | 5.61 KB | dstol |
#16 | 2723807-tax_menu_submenu_item-16.patch | 5.38 KB | akalata |
| |||
#13 | 2723807-tax_menu_submenu_item-13.patch | 144.56 KB | akalata |
Comments
Comment #2
sic CreditAttribution: sic commented+1
Comment #3
sic CreditAttribution: sic commentedThe core menu_ui provides a nice way to select an existing menu link, it could look something like this:
But I didnt quite figure out how to use that to place the term menu items under that parent. This is really urgent guys.
Also, a depth limit would be pretty helpful.
Comment #4
sic CreditAttribution: sic commentedOkay guys, I figured it out but its far away from nice or finished.
There are 2 new fields: Depth and Parent Menu item.
With depth you can set how many levels of the vocab tree will be loaded.
And with parent menu item you can actually set a parent of any menu (currently restricted to the main menu).
Changing any settings (like depth) may complete destroy the sub menu and you have to set the menu plus menu parent, I havent tested what happens if you specify another menu than your menu parent is in.
Lots to do but this works for now! Really looking forward to an official solution to this.
Better uninstall and reenable the module.
Comment #5
webcr8 CreditAttribution: webcr8 commentedMay I say a big thank you to Sic, exactly what I needed!
Comment #6
dstol@sic, would it be possible to get a patch against 8.x-3.x?
Comment #7
sic CreditAttribution: sic commentedyou can download the zip and make a patch from that, if you like!
Comment #8
rphair CreditAttribution: rphair as a volunteer commentedThis is such a desirable feature I have no choice but to try to keep this moving forward. From dates of @sic comments the code in the ZIP file has to derive from 8.x-3.2 given its release back in March: looks like it from the diff as well. I had two problems with the code:
1) as the author describes above, it's hobbled so you can only select a menu item on the
<Main navigation>
menu (src/Form/TaxonomyMenuForm.php:91
). As included in this patch, I had to comment out that line to test it on a custom menu, making all menu items on the site available.... better would be to focus the "Parent menu link" on the choice for "Menu" higher up in the configuration form.2) It seems to work fine on the
<Main navigation>
menu, but when I chose "Menu" to be a custom menu, and selected a "Parent menu link" to be an item on that menu, the taxonomy terms weren't rooted there: they were just planted at the root of the menu.Comment #9
akalata CreditAttribution: akalata commentedI'm attaching a reroll of #8 against 8.x-3.x-dev, along with my improvement attempts.
I don't think we need both "menu" and "menu_parent" settings; the user can just pick the root of the menu they want to use if that's the case. There will need to be an update written to convert existing settings, though. Since the existing link creation wants to know the parent menu explicitly, maybe we can change the "menu_parent" option to generate dynamically based on which "menu" is selected. I haven't done that yet though, so both options will need to be filled in and match right now.
I'm also not too keen on adding the "depth" option here; it could almost be its own issue. We would also need to determine which option takes precedence: does the parent menu item selected drive the max depth value, or does the selected max depth value drive which menu items may be selected as a parent?
TL;DR: Latest patch should now work for any menu, but there's likely still more to do here.
Comment #13
akalata CreditAttribution: akalata commentedI've fixed the existing tests, but there's nothing yet that tests for depth below a specific menu item.
Comment #16
akalata CreditAttribution: akalata commentedNot sure what happened with that patch. Let's try this one.
Comment #17
agoradesign CreditAttribution: agoradesign commentedWorks great for me!
Comment #18
dani3lr0se CreditAttribution: dani3lr0se as a volunteer commentedThanks @akalata! #16 works well for me also. I like the idea of having submenus in taxonomy menus. I'd agree with you though, it doesn't seem like the "Depth" option is necessary. We could just make a new taxonomy menu and then select a parent link in the menu. Not a bad idea, but maybe not needed? I tried to play around with adding the different depths and couldn't really figure it out, but then again, maybe it's just a user error.. ;) Nice work though. :)
Should this be "RTBC" or "Needs work"?
Comment #20
dstolRerolled against 8.x-3.x.
Comment #22
dstolHelps if I submit patches with diff prefixes.
Comment #24
dstolYikes and without parse errors.
Comment #26
dstolThanks everyone!
Comment #27
IngoVals CreditAttribution: IngoVals commentedIt seems to me that parent menu link isn't saving properly, at least it always seems to reset back to root. I noticed some other guy talking about the same problem over at github.
https://github.com/unn/taxonomy_menu/issues/6
Are we using it wrong? Should we reopen this issue or create a new one?
Also confusing to have an option to pick menu, and then parent menu link that includes all menus at it seems. With this method couldn't we just ignore the original menu dropdown and just use the parent menu link?
Comment #28
IngoVals CreditAttribution: IngoVals commentedI think we can safely disregard #27. It works fine for me, I must have had some settings wrong (though I'm not sure which).
Comment #29
akalata CreditAttribution: akalata commentedFrom #27:
]
Agreed, I hadn't gotten around to figuring out how to get the menu name from the parent menu link item -- both the menu and the item were needed for the code to work, iirc. :)