Problem/Motivation
Currently, when one wants to display multiple level menus, the only output available is dropdown. However, it may be the case that a themer may want a menu, without dropdowns, such as with a vertical menu in the sidebar or footer.
Steps to reproduce
- Ensure the main menu has at least one menu with a sub-link.
- Under Structure > Block Layout, place a Main Menu block within the Content region.
Proposed resolution
Dropdown links in nav should be optional.
There are a myriad of ways a themer may tackle this, but to provide a simple approach, we should consider making dropdown an optional config within the nav component.
Comments
Comment #2
doxigo commentedHey James, thanks for the suggestion, at this point we probably won't be adding features to 4.x version but rather work on 5.x, we can backport it if applicable but please feel free to provide a MR
Thanks
Comment #4
jcandan commentedNot sure that my default boolean for
is_dropdownis a good implementation. Is there a better way to set default to true and ensure only a boolean is accepted? My twig-fu is lacking a little.Comment #5
jcandan commentedFor those wishing to know how to target menus within a region, this may be helpful:
With the above, I would be able to target a the main menu within the content region, and specify that it not be dropdown links.
Comment #7
doxigo commentedThanks for the work James, merged
Comment #9
doxigo commentedJames seems like there's a typo + some issues of importing the same `nav.twig` file within itself, I have to revert this or please provide a MR
Comment #10
dkosbob commentedThis change also has the unintended effect of applying the
.dropdownclass on eachnav_itemunlessis_dropdownis explicitly set to false/null, even if there are no children menu items and the rest of the dropdown code isn't executed.I've made a change to address that and fix the typo mentioned. The template is including itself on line 56 -
I don't know whether twig allows that or not.It doesn't seem to cause any problems in my tests.Sorry for the patch. I tried to fork or re-open the fork but couldn't quite figure it out.
Comment #11
doxigo commentedNo longer supported/outdated, closing - feel free to open a MR if applicable.
Comment #13
andyz commentedThis was closed without integrating the change that conditions the "is_dropdown" class on `item.is_expanded` and `item.is_below`. A recent change broke the patch, so I'm uploading a new one.