#################### User site navigation #################### .. highlight:: html+django There are four template tags for use in the templates that are connected to the menu: * :ttag:`show_menu` * :ttag:`show_menu_below_id` * :ttag:`show_sub_menu` * :ttag:`show_breadcrumb` 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. .. templatetag:: show_menu ********* show_menu ********* The ``show_menu`` tag renders the navigation of the current page. You can overwrite the appearance and the HTML if you add a ``menu/menu.html`` template to your project or edit the one provided with django CMS. ``show_menu`` takes six optional parameters: ``start_level``, ``end_level``, ``extra_inactive``, ``extra_active``, ``namespace`` and ``root_id``. The first two parameters, ``start_level`` (default=0) and ``end_level`` (default=100) specify from which level the navigation should be rendered and at which level it should stop. If you have home as a root node (i.e. level 0) and don't want to display the root node(s), set ``start_level`` to 1. The third parameter, ``extra_inactive`` (default=0), specifies how many levels of navigation should be displayed if a node is not a direct ancestor or descendant of the current active node. The fourth parameter, ``extra_active`` (default=100), specifies how many levels of descendants of the currently active node should be displayed. The fifth parameter, ``namespace``, is currently not implemented. The sixth parameter ``root_id`` specifies the id of the root node. You can supply a ``template`` parameter to the tag. Some Examples ============= Complete navigation (as a nested list):: {% load menu_tags %} Navigation with active tree (as a nested list):: Navigation with only one active extra level:: Level 1 navigation (as a nested list):: Navigation with a custom template:: {% show_menu 0 100 100 100 "myapp/menu.html" %} .. templatetag:: show_menu_below_id ****************** show_menu_below_id ****************** If you have set an id in the advanced settings of a page, you can display the sub-menu of this page with a template tag. For example, we have a page called meta that is not displayed in the navigation and that has the id "meta":: You can give it the same optional parameters as ``show_menu``:: Unlike :ttag:`show_menu`, however, soft roots will not affect the menu when using :ttag:`show_menu_below_id`. .. templatetag:: show_sub_menu ************* show_sub_menu ************* Displays the sub menu of the current page (as a nested list). The first argument, ``levels`` (``default=100``), specifies how many levels deep the sub menu should be displayed. The second argument, ``root_level`` (``default=None``), specifies at what level, if any, the menu should have its root. For example, if root_level is 0 the menu will start at that level regardless of what level the current page is on. The third argument, ``nephews`` (``default=100``), specifies how many levels of nephews (children of siblings) are shown. Fourth argument, ``template`` (``default=menu/sub_menu.html``), is the template used by the tag; if you want to use a different template you **must** supply default values for ``root_level`` and ``nephews``. Examples:: Rooted at level 0:: Or with a custom template:: .. templatetag:: show_breadcrumb *************** show_breadcrumb *************** Show the breadcrumb navigation of the current page. The template for the HTML can be found at ``menu/breadcrumb.html``.:: {% show_breadcrumb %} 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``::