سؤال

Can you give me an example how can i use Navigation Nodes?

Cannot find examples in documentation.

There is this {{ node }} but where is it coming from?

Particalarly i am intereisted in {{ node.is_leaf_node }}.

هل كانت مفيدة؟

المحلول

Each navigation node is simply a link/entry in your menu tree so they are generated from your page layout, for example:

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

creates a menu with each page representing a node in the menu tree.

There's an example of them working in the default menu.html template (where child is a node in the menu):

{% 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 %}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top