In this Support topic, sarahann seeks to reuse Discourse’s built-in hamburger menu functionality for a custom header on mobile, avoiding rebuilding the open/close logic from scratch. She explores extending widgets and using connectors but finds limitations. simon suggests reviewing the brand header theme component as a reference. awesomerobot provides a working example using a custom ‘pizza menu’ widget attached to the header via api.decorateWidget, including toggle logic. sarahann asks about attaching the menu to a custom HTML element (e.g., in head_tag.html), prompting awesomerobot to redirect to the brand header’s approach of creating a new widget with its own toggle action. kimardenmiller and Queth ask how to customize panelContents with HTML and icons — Queth wants to add a chat login form. ngets and spirobel explore modifying the core hamburger-menu widget directly using api.reopenWidget, with spirobel successfully inserting custom dropdowns via unshift. ngets follows up asking how to position the menu after the search icon and insert custom HTML — the thread demonstrates that while Discourse’s plugin API supports deep customization, it often requires understanding widget architecture and DOM attachment points. The consensus leans toward reusing or extending existing widgets rather than building from scratch.
I could create the hamburger and menu with my knowledge of css/html/js. But I was hoping for a way to use the functionality that discourse has already implemented (opening, closing, etc..).
Any suggestions on how to achieve this?
I thought maybe I would be able to extend the widget for the current navigation, change the settings, then attach it to the html I have written for my nav. But the connectors seemed to be predefined, and I wasnt sure how to connect my widget to my html. This might not be the right direction at all either…
This is slightly rough but should get you 99% of the way there when it comes to having an additional menu item with a dropdown panel. Calling this one a pizza menu . Add this to your header.html file.
Ah ok in that case you’re looking at something more like what @simon mentioned in the brand header theme component, I was attaching the action to the existing header widget… the brand header adds it to a new one. The new widget here w/ toggleHamburger:
Thank you for this code. Can you point me in the right direction on filling out the panelContents? I see some indication, but not sure how it all links together.
hello! I know this is an old topic but this is almost what I’m looking for/trying to do. So therefore I post here (instead of making a new topic). Please bear in mind that I am not a developer and I don’t know how the plugins work and I cannot write javascript. But I know how to copy-paste code
What I’m trying to do is add login to a chatroom inside a dropdown menu. Thus, I want a “chat” icon, and in the dropdown menu will be an input field and a submit button, and some help text / link to help page.
Can I adapt your code then, instead of the ‘cutlery’ icon a ‘chat’ icon, how to do that?
and secondly, how can I insert HTML code instead of the ‘hello world’ statement. (basically how to enter HTML in there?
haha by coincidence I am looking at exactly the same thing too. I think the best way is to reopen the hamburger-menu widget and override the html method.
I will unshift my widget in front of the faq thingy. I didnt check if it works, but that will be my approach
Here it seems to work