django-cms示例中的导航节点



你能给我一个例子,我如何使用导航节点?

在文档中找不到示例。

有这个{{ node }},但它是从哪里来的?

我对{{ node.is_leaf_node }}特别感兴趣。

每个导航节点只是菜单树中的一个链接/条目,因此它们是从页面布局中生成的,例如:

- Home
  - About
  - Projects
    - Project A
    - Project B
  - Contact

创建一个菜单,每个页面表示菜单树中的一个节点。

有一个在默认的menu.html模板中工作的例子(其中child是菜单中的一个节点):

{% load menu_tags %}
{% for child in children %}
<li class="{% if child.selected %}selected{% endif %}{% if child.ancestor %}ancestor{% endif %}{% if child.sibling %}sibling{% endif %}{% if child.descendant %}descendant{% endif %}">
    <a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
    {% if child.children %}
    <ul>
        {% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
    </ul>
    {% endif %}
</li>
{% endfor %}

最新更新