[Answered ]-How can you create multiple menus with django-cms

2👍

Depends what you want to do really, but I’ve got a base template which has a navigation menu at the top and a sitemap submenu at the bottom.

So starting with the navigation;

{% show_menu 1 100 100 100 "partials/navigation.html" %}

Which uses the template;

{% load cms_tags menu_tags cache cms_page %}

{% for child in children %}

    <li>
        <a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">
            {{ child.get_menu_title }}
        </a>
        {% if child.children and child.level <= 4 %}
            <ul>
                {% show_menu from_level to_level extra_inactive extra_active template '' '' child %}
            </ul>
        {% endif %}
    </li>

{% endfor %}

Then the sitemap;

{% show_sub_menu 2 1 1 "partials/sitemap.html" %}

And sitemap.html

{% load cms_tags cms_page cache %}

{% if children %}

    {% for child in children %}

        <ul class="site-footer__column">
            <li>
                <h4>
                    <a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">
                        {{ child.get_menu_title }}
                    </a>
                </h4>
            </li>

            {% if child.children %}
                {% for baby in child.children %}

                    <li class="footer_sub">
                        <a href="{{ baby.attr.redirect_url|default:baby.get_absolute_url }}">
                            {{ baby.get_menu_title }}
                        </a>
                    </li>
                {% endfor %}
            {% endif %}

        </ul>

    {% endfor %}
{% endif %}

Understanding the options (numbers) you can provide for a menu can enable you to display different parts of your site, but if the built in menu tags don’t suit your needs, you could write a custom menu tag.

The standard menu docs are here; http://docs.django-cms.org/en/3.2.2/reference/navigation.html

And here are the docs for customising your menus; http://docs.django-cms.org/en/3.2.2/how_to/menus.html

Leave a comment