Menus and navigation
There are four template tags for use in the templates that are connected to the
menu:
To use any of these template tags, you need to have {% load menu_tags %}
in
your template before the line on which you call the template tag.
Note
Please note that menus live in the menus
application, which though
tightly coupled to the cms
application exists independently of it.
Menus are usable by any application, not just by django CMS.
show_breadcrumb
Show the breadcrumb navigation of the current page. The template for the HTML
can be found at menu/breadcrumb.html
.:
Or with a custom template and only display level 2 or higher:
{% show_breadcrumb 2 "myapp/breadcrumb.html" %}
Usually, only pages visible in the navigation are shown in the
breadcrumb. To include all pages in the breadcrumb, write:
{% show_breadcrumb 0 "menu/breadcrumb.html" 0 %}
If the current URL is not handled by the CMS or by a navigation extender,
the current menu node can not be determined.
In this case you may need to provide your own breadcrumb via the template.
This is mostly needed for pages like login, logout and third-party apps.
This can easily be accomplished by a block you overwrite in your templates.
For example in your base.html
:
<ul>
{% block breadcrumb %}
{% show_breadcrumb %}
{% endblock %}
<ul>
And then in your app template:
{% block breadcrumb %}
<li><a href="/">home</a></li>
<li>My current page</li>
{% endblock %}
Properties of Navigation Nodes in templates
Is it the last in the tree? If true it doesn’t have any children.
The level of the node. Starts at 0.
The level of the node from the root node of the menu. Starts at 0.
If your menu starts at level 1 or you have a “soft root” (described
in the next section) the first node would still have 0 as its menu_level
.
{{ node.get_absolute_url }}
The absolute URL of the node, without any protocol, domain or port.
The title in the current language of the node.
If true this node is the current one selected/active at this URL.
If true this node is an ancestor of the current selected node.
If true this node is a sibling of the current selected node.
If true this node is a descendant of the current selected node.
If true this node is a soft root. A page can be marked as a soft root
in its ‘Advanced Settings’.
Menu system classes and function