{% load menu_tags i18n %} {% with nav_level_max=4 nav_level_add_overview=1 nav_level_min=1 %} {# Show only up to nav_level_max levels of navigation in the submenu #} {% if children and request.current_page.level < nav_level_max %} {# Show an Overview menu item that points to the first level nav item #} {% if request.current_page.level == nav_level_add_overview %}
  • {% trans "Overview" %}
  • {% endif %} {% for child in children %}
  • {{ child.get_menu_title }}
  • {% endfor %} {% comment %} We're now in a leaf node: either it has no children, or we've reached nav_level_max. In any case, no children nodes are returned from the show_sub_menu tag, so if we want to show this node and its siblings in the navigation, we'll need to resort to its parent and fetch its children. {% endcomment %} {% elif request.current_page.level == nav_level_max or current_page.children.all.count == 0 %} {% if request.current_page.level == nav_level_min %} {# Show an Overview menu item that points to the first level nav item #}
  • {% trans "Overview" %}
  • {% else %} {# Show an Overview menu item that points to the first level nav item #} {% if request.current_page.parent.level == nav_level_add_overview %}
  • {% trans "Overview" %}
  • {% endif %} {% for sibling in request.current_page.parent.children.all %} {% if sibling.in_navigation and sibling.get_slug %}
  • {% if request.current_page == sibling %} {{ sibling.get_menu_title }} {% else %} {{ sibling.get_menu_title }} {% endif %}
  • {% endif %} {% endfor %} {% endif %} {% endif %} {% endwith %}