Django CMS Show_Menu示例不适用于多级菜单

时间:2019-05-28 10:01:28

标签: django django-cms

base.html:

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                   {% show_menu 0 1 100 100 "menu.html" %}
                </ul>

            </div>

menu.html:

{% load i18n menu_tags cache %}
{% for child in children %}
    <li class="child{% if child.selected %} selected{% endif %}{% if child.ancestor %} ancestor{% endif %}{% if child.sibling %} sibling{% endif %}{% if child.descendant %} descendant{% endif %}{% if child.children %} dropdown{% endif %}">

        <a {% if child.children %}class="dropdown-toggle" data-toggle="dropdown"{% endif %} href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">
            <span>{{ child.get_menu_title }}</span>{% if child.children|length %}<span class="caret"></span>{% endif %}
        </a>

        {% if child.children %}
            <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
                {% show_menu from_level to_level extra_inactive extra_active "dropdownmenu.html" "" "" child %}
            </ul>
        {% endif %}

    </li>
    {% if class and forloop.last and not forloop.parentloop %}{% endif %}

{% endfor %}

dropdownmenu.html:

{% load i18n menu_tags cache  %}
{% for child in children %}
    <li {% if child.children %}class="dropdown-submenu"{% else %} {% endif %}>
        <a tabindex="-1" href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
        {% if child.children %}
            <ul class="dropdown-menu">
                {% show_menu from_level to_level extra_inactive extra_active "dropdownmenu.html" "" "" child %}
            </ul>
        {% endif %}

    </li>
{% endfor %}

子菜单没有显示

1 个答案:

答案 0 :(得分:0)

我只是有这个问题。我发布了页面,然后可以在呈现的菜单中看到它们。