backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 39 forks source link

Enable dropdown menu for menus in header block #5330

Open yorkshire-pudding opened 2 years ago

yorkshire-pudding commented 2 years ago

Description of the need There are some genuine use cases where drop down menus are needed for a site's primary navigation but for a given theme, the best place for a menu is as part of the header block, either for the look or because the primary navigation block doesn't work well in that theme.

Proposed solution It would be good to enable the menu in the "Header block" to be a dropdown menu.

Alternatives that have been considered Some themes work quite well with having a primary navigation block in the header and the menu disabled in the header block.

Is there a Drupal or Backdrop contributed module that accomplishes this? Not aware

stpaultim commented 2 years ago

I am trying to achieve a similar result.

I would like this layout in the header, but with a dropdown menu for primary navigation. The header block would be great, if I could enable dropdown menu there.

I'm not sure how else to achieve this without custom theming (bummer).

image

Another example: https://ashefarmersmarket.com/

image

Girlwithasmile commented 2 years ago

Hello I am a contributer at openforce 2022. Shall I work on this if its still open?

yorkshire-pudding commented 2 years ago

Hi @Girlwithasmile - Any that are open, unless there is a comment suggesting someone is actively working on it then is fine to look at.

Girlwithasmile commented 2 years ago

Just a confusion, where is the dropdown menu needed? In the actual site or the site user will prepare?

yorkshire-pudding commented 2 years ago

Hi @Girlwithasmile

image

The header block, which also contains logo, sitename, slogan if applicable also has the option to contain a menu. However, that menu will never be a dropdown.

klonos commented 2 years ago

...In the actual site or the site user will prepare?

@Girlwithasmile to supplement what @yorkshire-pudding said above, and to specifically answer your question, when you install a fresh Backdrop site the header block is configured to hold the "Account menu". That menu has the following links available out of the box (see /admin/structure/menu/manage/user-menu):

All these links are on the same level, whereas if you check another menu, like the administration menu (/admin/structure/menu/manage/management), you will see that it has multiple links in various levels. When a top-level menu item has "children" menu items and you hover over it, it gets automatically expanded, to reveal the children menu items.

If you add some children menu items to the "Account menu" menu, you will notice that these menu items are not shown when you hover over their "parent" menu item - this is the problem we are trying to solve here. So I would suggest that after you have added some menu items with children items in the "Account menu" menu, you then work towards making it so that hovering over menu items reveals their children.

I hope this helps.

stpaultim commented 2 years ago

@Girlwithasmile - Any questions? We have office hours this week, if you need help: https://backdropcms.org/news/events/office-hours-2

jenlampton commented 2 years ago

I'm not sure this is a good candidate for core, but I'd love to see it evolve as a contrib module.

I could see the module adding settings into the header block that match the settings in the menu block.

Then in X_preprocess_header() we'd override the variable $variables['menu'] so instead of calling

$variables['menu'] = $menu ? theme('links__header_menu', array('links' => $menu)) : NULL;

we call menu_tree_output() to generate the menu markup like we do in system_menu_block_build()

argiepiano commented 6 months ago

There was a Forum question about this. https://forum.backdropcms.org/forum/dropdown-issues-bootstrap-5-lite

Was there any progress adding this functionality as contrib? @jenlampton's suggestion seems promising.

argiepiano commented 6 months ago

I have created a simple module to allow site builders to select dropdown style for the header block menu.

https://backdropcms.org/project/header_dropdown_menu

and

https://github.com/backdrop-contrib/header_dropdown_menu

izmeez commented 6 months ago

@argiepiano The header_dropdown_menu works great. I used a direct download of the latest code.

izmeez commented 2 months ago

@argiepiano and anyone else interested, I just opened a new issue on that module, https://github.com/backdrop-contrib/header_dropdown_menu/issues/1