Basics: How to make a menu?

330 views
Skip to first unread message

Shanti Kanhai

unread,
Mar 22, 2016, 5:47:33 PM3/22/16
to Wagtail support

I've been trying different models I have found on the internet to make a simple header menu that is linked to the Wagtail checkboxes in the admin of my website, but have not been able to figure it out. Should it be a plain Django menu or are there Wagtail templates tags that I must use? I assume the latter, since it needs to be linked to Wagtail's admin.

Much obliged!

Chris Rogers

unread,
Mar 31, 2016, 4:36:58 PM3/31/16
to Wagtail support
Hi Shanti,

template tags are a good way to create the menu.

A good place to start is the WagtailDemo site, which includes a two-level drop-down menu that is built using template tags:

You can see the template tags file, and the relevant functions here: 


The template tag is then implemented in the base.html file:


and the menu HTML itself:


I hope that helps. Please do ask more questions if necessary.

Cheers,
Chris

Shanti Kanhai

unread,
Apr 10, 2016, 7:26:37 PM4/10/16
to Wagtail support

Hi Chris,

Thanks for directing me in the right way! However it seems that these files only make a menu for parents and their children - how can I use them to include the children of children?

~ Shanti

Op donderdag 31 maart 2016 14:36:58 UTC-6 schreef Chris Rogers:

mron...@gmail.com

unread,
Apr 11, 2016, 11:50:49 AM4/11/16
to Wagtail support
has anyone worked with this example?

Mainderay

unread,
Apr 11, 2016, 5:50:18 PM4/11/16
to Wagtail support
I recently used the below example on a site for secondary menus (e.g.: sidebars) and a footer menu and it worked just great. I used the WagTail demo for the main menu as it had drop downs.

Happy to help if you have any questions!

-raymond

Mainderay

unread,
Apr 11, 2016, 5:55:59 PM4/11/16
to Wagtail support
Greeting Shanti,

I too have used the template tag menus by leveraging the extremely helpful Wagtail Demo site. In my case I didn't need a third level, but I did modify the menu in other ways. I was reticent at first, but I found that once I dug into the menu code, it really wasn't too hard to understand or modify. If you're comfortable doing so, I'd highly recommend rolling up your sleeves and deconstructing the Wagtail Demo example. If you run into any specific questions, I'm happy to help!

best,

-raymond
Reply all
Reply to author
Forward
0 new messages