0

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

在文档中找不到示例。

有这个{{ node }},但它来自哪里?

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

4

1 回答 1

3

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

- 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 %}
于 2013-03-31T18:46:30.543 回答