Tuesday 14 July 2020

WagtailMenu template example

I found it difficult to find an example of a Menu template example for WagtailMenus -> https://wagtailmenus.readthedocs.io/en/stable/


The 'menus' folder will go in the 'templates' folder of your app.  

This is a very simple example and does not include a Sub Menu .  Which will follow. 

{% load menu_tags %}
{% if menu_items %}
<nav class="nav-main">
<ul>
{% for item in menu_items %}
<li class="menu-item">
<a href="{{ item.href }}" class="icon {{ item.handle }}">{{ item.text }}</a>
</li>
{% endfor %}
</ul>
</nav>
{% endif %}

I've used 'handle' to store the class name I want, but this may not be suitable for you. 


No comments: