• Tutorials
    • 1. Installing django CMS
      • 1.1. Requirements
      • 1.2. Your working environment
        • 1.2.1. Create and activate a virtual environment
        • 1.2.2. Update pip inside the virtual environment
        • 1.2.3. Use the django CMS installer
        • 1.2.4. Start up the runserver
    • 2. Templates & Placeholders
      • 2.1. Templates
      • 2.2. Placeholders
      • 2.3. Static Placeholders
      • 2.4. Rendering Menus
    • 3. Integrating applications
      • 3.1. Incorporate the polls application
        • 3.1.1. Install polls
        • 3.1.2. Improve the templates for Polls
      • 3.2. Set up a new polls_cms_integration application
        • 3.2.1. Create the application
        • 3.2.2. Add it to INSTALLED_APPS
    • 4. Plugins
      • 4.1. Create a plugin model
        • 4.1.1. The Plugin Class
        • 4.1.2. The template
      • 4.2. Test the plugin
    • 5. Apphooks
      • 5.1. Create an apphook
        • 5.1.1. Create the apphook class
        • 5.1.2. Remove the old polls entry from the project’s urls.py
        • 5.1.3. Restart the runserver
      • 5.2. Apply the apphook to a page
    • 6. Extending the toolbar
      • 6.1. Add a basic PollToolbar class
        • 6.1.1. Add a menu to the toolbar
        • 6.1.2. Add buttons to the toolbar
      • 6.2. Further refinements
      • 6.3. The complete cms_toolbars.py
    • 7. Extending the navigation menu
      • 7.1. Create the navigation menu
    • 8. Content creation wizards
    • 9. Integrating a third-party application
      • 9.1. Basic installation
      • 9.2. Django settings
        • 9.2.1. INSTALLED_APPS
        • 9.2.2. THUMBNAIL_PROCESSORS
        • 9.2.3. ALDRYN_BOILERPLATE_NAME
        • 9.2.4. STATICFILES_FINDERS
        • 9.2.5. TEMPLATES
      • 9.3. Migrate the database
      • 9.4. Create a new apphooked page
      • 9.5. Add new News & Blog articles
  • How-to guides
    • Set-up
      • Install django CMS by hand
        • Install the django CMS package
        • Create a new project
        • Minimally-required applications and settings
        • Database
        • Using cms check for configuration
        • Further required configuration
        • Adding content-handling functionality
        • Launch the project
        • Next steps
    • Using core functionality
      • Use placeholders outside the CMS
        • Get started
        • Adding content to a placeholder
      • Serve multiple languages
        • Multilingual URLs
        • Store the user’s language preference
        • Working in templates
        • Configuring language-handling behaviour
      • Work with templates
        • static_placeholder
        • CMS_TEMPLATE
        • render_model
      • Manage caching
        • Set-up
      • Enable frontend editing for Page and Django models
        • Template tags
        • Page titles edit
        • Page menu edit
        • Editing ‘ordinary’ Django models
        • Filters
        • Context variable
      • Create sitemaps
        • Sitemap
        • Configuration
        • django.contrib.sitemaps
      • Manage Page Types
        • Creating Page Types
        • Managing Page Types
        • Selecting a Page Type
    • Creating new functionality
      • Create plugins
        • The simplest plugin
        • Troubleshooting
        • Storing configuration
        • Advanced
      • Create apphooks
        • The basics of apphook creation
        • Using an apphook
        • Managing apphooks
        • Adding menus to apphooks
        • Managing permissions on apphooks
        • Automatically restart server on apphook changes
        • Apphooks and placeholder template tags
      • Manage complex apphook configuration
        • Attaching an application multiple times
        • Apphook configurations
        • An example apphook configuration
      • Extend the Toolbar
        • Create a cms_toolbars.py file
        • Define and register a CMSToolbar sub-class
        • Populate the toolbar
        • Finding existing toolbar items
        • Control the position of items in the toolbar
        • Control how and when the toolbar appears
        • Modifying an existing toolbar
        • Detecting URL changes to an object
        • Frontend
      • Customise navigation menus
        • Menus
        • Attach Menus
        • Navigation Modifiers
      • Create content creation wizards
        • Create a content-creation wizard
      • Extend Page & Title models
        • Title vs Page extensions
        • Implement a basic extension
        • Using extensions
        • Complete toolbar API
      • Test your extensions
        • Testing Apps
        • Testing Plugins
    • Contributing
      • Contribute a patch
        • The basics
        • How to write a test
        • Submitting your code
  • Reference
    • API References
      • cms.api
        • Functions and constants
        • Example workflows
      • cms.constants
      • cms.app_base
    • Command Line Interface
      • Informational commands
        • cms list
        • cms check
      • Plugin and apphook management commands
        • cms delete-orphaned-plugins
        • cms uninstall
        • cms copy
        • cms copy lang
        • cms copy site
      • Moderation commands
        • cms moderator
        • cms publisher-publish
      • Maintenance and repair
        • fix-tree
        • fix-mptt
    • Configuration
      • The INSTALLED_APPS setting
      • The MIDDLEWARE setting
        • cms.middleware.utils.ApphookReloadMiddleware
      • Custom User Requirements
      • Required Settings
        • CMS_TEMPLATES
      • Basic Customisation
        • CMS_TEMPLATE_INHERITANCE
        • CMS_TEMPLATES_DIR
        • CMS_PLACEHOLDER_CONF
        • CMS_PLUGIN_CONTEXT_PROCESSORS
        • CMS_PLUGIN_PROCESSORS
        • CMS_APPHOOKS
      • Internationalisation and localisation (I18N and L10N)
        • CMS_LANGUAGES
        • Unicode support for automated slugs
      • Media Settings
        • CMS_MEDIA_PATH
        • CMS_MEDIA_ROOT
        • CMS_MEDIA_URL
        • CMS_PAGE_MEDIA_PATH
      • Advanced Settings
        • CMS_INTERNAL_IPS
        • CMS_REQUEST_IP_RESOLVER
        • CMS_PERMISSION
        • CMS_RAW_ID_USERS
        • CMS_PUBLIC_FOR
        • CMS_CACHE_DURATIONS
        • CMS_CACHE_PREFIX
        • CMS_PAGE_CACHE
        • CMS_PLACEHOLDER_CACHE
        • CMS_PLUGIN_CACHE
        • CMS_TOOLBARS
        • CMS_TOOLBAR_ANONYMOUS_ON
        • CMS_TOOLBAR_HIDE
        • CMS_DEFAULT_X_FRAME_OPTIONS
        • CMS_TOOLBAR_SIMPLE_STRUCTURE_MODE
        • CMS_PAGE_WIZARD_DEFAULT_TEMPLATE
        • CMS_PAGE_WIZARD_CONTENT_PLACEHOLDER
        • CMS_PAGE_WIZARD_CONTENT_PLUGIN
        • CMS_PAGE_WIZARD_CONTENT_PLUGIN_BODY
    • Form and model fields
      • Model fields
      • Form fields
    • Menus and navigation
      • show_menu
        • Some Examples
      • show_menu_below_id
      • show_sub_menu
      • show_breadcrumb
      • Properties of Navigation Nodes in templates
      • Modifying & Extending the menu
      • Menu system classes and function
        • menu application
        • cms application
    • Models
    • Permissions
    • Placeholders
    • Plugins
      • CMSPluginBase Attributes and Methods Reference
      • CMSPlugin Attributes and Methods Reference
    • Sitemaps
    • Template Tags
      • CMS template tags
        • Placeholders
        • render_placeholder
        • render_uncached_placeholder
        • show_placeholder
        • show_uncached_placeholder
        • page_lookup
        • page_url
        • page_attribute
        • render_plugin
        • render_plugin_block
        • render_model
        • render_model_block
        • render_model_icon
        • render_model_add
        • render_model_add_block
        • page_language_url
        • language_chooser
      • Toolbar template tags
    • Titles
    • The Toolbar
      • Classes and methods
      • Parameters
      • django CMS constants used in toolbars
    • Content creation wizards
      • Base Wizard
      • Base Wizard methods
        • get_description
        • get_title
        • get_success_url
        • get_weight
        • user_has_add_permission
      • wizard_pool
      • Wizard pool methods
        • is_registered
        • register
        • unregister
        • get_entry
        • get_entries
  • Key topics
    • Plugins
      • Why would you need to write a plugin?
      • Components of a plugin
        • CMSPluginBase
        • CMSPlugin
    • Application hooks (“apphooks”)
      • Multiple apphooks per application
      • Apphook configurations
    • Publishing
      • Code and Pages
    • Serving content in multiple languages
      • Basic concepts
        • How django CMS determines the user’s preferred language
        • How django CMS determines what language to serve
        • What django CMS shows in your menus
    • Internationalisation
      • URLs
      • How django CMS determines which language to serve
    • Permissions
      • Permission modes
      • Key user permissions
      • Permissions in Page permissions mode
        • Global and per-page permissions
        • Page permission options
        • Per-page permissions
      • Permission strategies
        • Use permissions on Groups, not on Users
        • Use Groups to build up permissions
    • Using touch-screen devices with django CMS
      • General
      • Device support
      • Your site’s frontend
      • Known issues
        • General issues
        • CKEditor issues
        • Django Admin issues
    • How the menu system works
      • Basic concepts
        • Soft Roots
        • Registration
        • Generators and Modifiers
        • Nodes
      • Menu system logic
        • The ShowMenu.get_context() method
        • The MenuPool.get_nodes() method
        • Menu Modifiers
    • Some commonly-used plugins
      • django CMS Core Addons
      • Other addons of note
      • Deprecated addons
    • Search and django CMS
    • Frontend integration
  • Contribute
    • Contributor Community
      • Django CMS Association
      • The dCA Tech Committee
        • Mission
        • Team
        • Tasks
        • Processes
    • Development policies
      • Reporting security issues
      • Review
        • Formal approval
      • Proposal and discussion of significant changes
      • Release schedule
      • Branches
      • Commits
        • Commit messages
        • Squashing commits
      • Changelog
    • How to contribute
      • Contributing code
        • In a nutshell
        • Basic requirements and standards
        • Frontend
      • Contributing documentation
        • Building the documentation
        • Spelling
        • Making a pull request
        • Documentation structure
        • Documentation markup
      • Contributing translations
    • Code and project management
      • Issues
        • Raising an issue
        • Getting your issue accepted
      • How we process tickets
        • django CMS ticket processing system rules
        • Status
        • Needs
        • Kinds and components
        • Other labels
        • Comments
      • Label reference
        • Statuses
        • Needs
        • Other
    • Running and writing tests
      • Running tests
        • Problems running the tests
        • Advanced testing options
      • Running Frontend Tests
        • Unit tests
        • Integration tests
      • Writing tests
        • What we need
    • Code of Conduct
      • Raising a concern
  • Release notes & upgrade information
    • 3.8.0 release notes
      • What’s new in 3.8.0
        • Improvements and new features
        • Bug Fixes
      • How to upgrade to 3.8
    • 3.7.4 release notes
      • What’s new in 3.7.4
        • Bug Fixes
    • 3.7.3 release notes
      • What’s new in 3.7.3
        • Bug Fixes
    • 3.7.2 release notes
      • What’s new in 3.7.2
        • Bug Fixes
        • Improvements and new features
      • How to upgrade to 3.7.2
    • 3.7.1 release notes
      • What’s new in 3.7.1
        • Bug Fixes
        • Improvements and new features
    • 3.7.0 release notes
      • What’s new in 3.7.0
        • Improvements and new features
      • How to upgrade to 3.7
      • Create a new django CMS 3.7 project
        • On the Divio Cloud
        • Using the django CMS Installer
      • Contributors to this release
    • 3.6.1 release notes
      • What’s new in 3.6.1
        • Bug Fixes
    • 3.6.0 release notes
      • What’s new in 3.6.0
        • Improvements and new features
        • Removal of deprecated functionality
      • How to upgrade to 3.6
      • Create a new django CMS 3.6 project
        • On the Divio Cloud
        • Using the django CMS Installer
      • Contributors to this release
    • 3.5.4 release notes
      • What’s new in 3.5.4
        • Bug Fixes
    • 3.5.3 release notes
      • What’s new in 3.5.3
        • Bug Fixes
    • 3.5.2 release notes
      • What’s new in 3.5.2
        • Bug Fixes
    • 3.5.1 release notes
      • What’s new in 3.5.1
        • Bug Fixes
    • 3.5.0 release notes
      • What’s new in 3.5.0
        • Improvements and new features
        • Bug Fixes
        • Removal of deprecated functionality
        • Backward-incompatible changes
      • How to upgrade to 3.5
      • Create a new django CMS 3.5 project
        • On the Divio Cloud
        • Using the django CMS Installer
      • Contributors to this release
    • 3.4.7 release notes
      • What’s new in 3.4.7
        • Bug Fixes
    • 3.4.6 release notes
      • What’s new in 3.4.6
        • Bug Fixes
    • 3.4.5 release notes
      • What’s new in 3.4.5
        • Bug Fixes
        • Improvements and new features
    • 3.4.4 release notes
      • What’s new in 3.4.4
        • Bug Fixes
        • Improvements and new features
        • Deprecations
      • Backward incompatible changes
        • Page methods
        • Placeholder utilities
    • 3.4.3 release notes
      • What’s new in 3.4.3
        • Security Fixes
        • Thanks
    • 3.4.2 release notes
      • What’s new in 3.4.2
        • Bug Fixes
        • Improvements and new features
        • Deprecations
        • Other changes
    • 3.4.1 release notes
      • What’s new in 3.4.1
        • Bug Fixes
    • 3.4 release notes
      • What’s new in 3.4
      • Upgrading to 3.4
      • Backward incompatible changes
        • Apphooks & Toolbars
        • Permissions
        • Manual plugin rendering
    • 3.3 release notes
      • What’s new in 3.3
      • Upgrading to 3.3
        • Deprecation of Old-Style Page Wizard Settings
      • Backward incompatible changes
        • Management commands
        • Signature changes
    • 3.2.5 release notes
      • What’s new in 3.2.5
        • Bug Fixes
        • DjangoCMS Text CKEditor
    • 3.2.4 release notes
      • What’s new in 3.2.4
        • Bug Fixes
        • DjangoCMS Text CKEditor
    • 3.2.3 release notes
      • What’s new in 3.2.3
        • Bug Fixes
    • 3.2.2 release notes
      • What’s new in 3.2.2
        • Improvements
        • Bug Fixes
        • Model Relationship Back-References and Django 1.9
        • Notice of Upcoming Change in 3.3
        • Treebeard corruption
        • DjangoCMS Text CKEditor
    • 3.2.1 release notes
      • What’s new in 3.2.1
        • Improvements
        • Bug Fixes
        • Treebeard corruption
        • DjangoCMS Text CKEditor
    • 3.2 release notes
      • What’s new in 3.2
      • Changes that require attention
        • Touch interface support
        • Bug-fixes
        • Content wizards
        • Renaming cms_app, cms_toolbar, menu modules
        • New ApphookReloadMiddleware
        • For developers
        • New structure board
        • Replaced the sideframe with an overlay
        • New startup page
      • Known issues
      • Backward-incompatible changes
      • Upgrading django CMS 3.1 to 3.2
      • Pending deprecations
    • 3.1.5 release notes
      • What’s new in 3.1.5
        • Bug Fixes
        • Treebeard corruption
        • DjangoCMS Text CKEditor
    • 3.1.4 release notes
      • What’s new in 3.1.4
        • Bug Fixes
        • Treebeard corruption
    • 3.1.3 release notes
      • What’s new in 3.1.3
        • Bug Fixes
        • Thanks
    • 3.1.2 release notes
      • What’s new in 3.1.2
        • Bug Fixes
    • 3.1.1 release notes
      • What’s new in 3.1.1
        • Bug Fixes
        • Potentially backward incompatible changes
        • Thanks
    • 3.1 release notes
      • What’s new in 3.1
        • Switch from MPTT to MP
        • Dropped support for Django 1.4 and 1.5
        • South is now an optional dependency
        • Changes to PlaceholderAdmin.add_plugin
        • Migrations moved
        • Plugins migrations moving process
        • Structure mode permission
        • Simplified loading of view restrictions in the menu
        • Toolbar API extension
        • Per-namespace apphook configuration
        • Improvements to the toolbar user interface
        • Placeholder language fallback default to True
        • New template tags
        • Plugin table naming
        • cms.context_processors.media replaced by cms.context_processors.cms_settings
      • Upgrading django CMS 3.0 to 3.1
        • Preliminary steps
        • Settings update
        • Update the database
    • 3.0.16 release notes
      • Bug-fixes
    • 3.0.15 release notes
      • What’s new in 3.0.15
        • Bug Fixes
        • Thanks
    • 3.0.14 release notes
      • What’s new in 3.0.14
        • Bug Fixes
        • Potentially backward incompatible changes
        • Thanks
    • 3.0.13 release notes
      • What’s new in 3.0.13
        • Bug Fixes
    • 3.0.12 release notes
      • What’s new in 3.0.12
        • Bug Fixes
    • 3.0.11 release notes
      • What’s new in 3.0.11
        • Bug Fixes
        • Other
    • 3.0.10 release notes
      • What’s new in 3.0.10
        • Bug Fixes
    • 3.0.9 release notes
      • What’s new in 3.0.9
        • Bug Fixes
    • 3.0.8 release notes
      • What’s new in 3.0.8
        • Bug Fixes
    • 3.0.7 release notes
      • What’s new in 3.0.7
        • Bug Fixes
        • Project & Community Governance
    • 3.0.6 release notes
      • What’s new in 3.0.6
        • Django 1.7 support
        • Extended Custom User Support
        • CMSPlugin.get_render_template
        • Simplified toolbar API for page extensions
    • 3.0.3 release notes
      • What’s new in 3.0.3
        • New Alias Plugin
        • New Context Menu API
        • Apphook Permissions
    • 3.0 release notes
      • What’s new in 3.0
        • New Frontend Editing
        • New Toolbar
        • New Page Types
        • Experimental Python 3.3 support
        • Better multilingual editing
        • CMS_SEO_FIELDS
        • CMS_MENU_TITLE_OVERWRITE
        • Plugin fallback languages
        • language_chooser
        • Undo and Redo
        • Plugins removed
        • Plugin Context Processors take a new argument
        • Apphooks
        • PlaceholderAdmin
        • Placeholder object permissions
        • Placeholders are pre-fillable with default plugins
        • Custom modules and plugin labels in the toolbar UI
        • New copy-lang subcommand
        • Frontend editor for Django models
        • New Page related_name to Site
        • Moved all template tags to cms_tags
        • getter and setter for translatable plugin content
        • No more DB table-name magic for plugins
        • Added support for custom user models
        • Page caching
        • Placeholder caching
        • Plugin caching
        • Per-page Clickjacking protection
        • CMS_TEMPLATE context variable
      • Upgrading from 2.4
      • Pending deprecations
        • placeholder_tags
        • cms.context_processors.media
    • 2.4 release notes
      • What’s new in 2.4
        • Introducing Django 1.5 support, dropped support for Django 1.3 and Python 2.5
        • Migrations overhaul
        • Added delete orphaned plugins command
        • Added a check command
        • CMS_MODERATOR
        • Added Fix MPTT Management command
        • Removed the MultilingualMiddleware
        • Added LanguageCookieMiddleware
        • CMS_LANGUAGES
        • CMS_FLAT_URLS
        • Plugins in Plugins
        • New way to handle django CMS settings
        • Added cms.constants module
        • django-reversion integration changes
        • Changes to the show_sub_menu template tag
        • PlaceholderAdmin support i18n
        • Added CMS_RAW_ID_USERS
      • Backwards incompatible changes
        • New minimum requirements for dependencies
      • Pending deprecations
    • 2.3.4 release notes
      • What’s new in 2.3.4
        • WymEditor fixed
        • Moved Norwegian translations
        • Added support for time zones
        • Fixed slug clashing
        • Prevent unnamed related names for PlaceholderField
        • Two fixes to page change form
    • 2.3.3 release notes
      • What’s new in 2.3.3
        • Restored Python 2.5 support
      • Pending deprecations
    • 2.3.2 release notes
      • What’s new in 2.3.2
        • Google map plugin
    • 2.3 release notes
      • What’s new in 2.3
        • Introducing Django 1.4 support, dropped support for Django 1.2
        • Lazy page tree loading in admin
        • Toolbar isolation
        • Plugin cancel button fixed
        • Tests refactor
        • Moving text plugins to different placeholders no longer loses inline plugins
        • Minor improvements
      • Backwards incompatible changes
        • New minimum requirements for dependencies
        • Registering a list of plugins in the plugin pool
      • Pending deprecations
    • 2.2 release notes
      • What’s new in 2.2
        • django-mptt now a proper dependency
        • Django 1.3 support
        • View permissions
      • Backwards incompatible changes
        • django-sekizai instead of PluginMedia
        • Toolbar must be enabled explicitly in templates
        • Static files moved to /static/
      • Features deprecated in 2.2
        • django-dbgettext support
    • Upgrading from 2.1.x and Django 1.2.x
      • Upgrading dependencies
      • Updates to settings.py
      • Template Updates
      • Database Updates
      • Static Media
  • Using django CMS
    • Tutorial
      • Log in
      • Create a page
        • Create your first page
        • Publish a page
        • Create a second page
      • Changing page settings
      • Structure and content modes
        • Add a second plugin
    • Reference for content editors
      • Page admin
        • The interface
        • Admin views & forms
      • Working with admin in the frontend
        • Redirection
The django CMS Association

The django CMS Association is a non-profit organisation that funds and steers the development of django CMS, and nurtures its world-wide community of developers and users.

Join us
django cms
Divio
  • Docs  » 
  • Reference  » 
  • Menus and navigation

Menus and navigation¶

There are four template tags for use in the templates that are connected to the menu:

  • show_menu

  • show_menu_below_id

  • show_sub_menu

  • 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.

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 %}
<ul>
    {% show_menu 0 100 100 100 %}
</ul>

Navigation with active tree (as a nested list):

<ul>
    {% show_menu 0 100 0 100 %}
</ul>

Navigation with only one active extra level:

<ul>
    {% show_menu 0 100 0 1 %}
</ul>

Level 1 navigation (as a nested list):

<ul>
    {% show_menu 1 %}
</ul>

Navigation with a custom template:

{% show_menu 0 100 100 100 "myapp/menu.html" %}

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”:

<ul>
    {% show_menu_below_id "meta" %}
</ul>

You can give it the same optional parameters as show_menu:

<ul>
    {% show_menu_below_id "meta" 0 100 100 100 "myapp/menu.html" %}
</ul>

Unlike show_menu, however, soft roots will not affect the menu when using show_menu_below_id.

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:

<ul>
    {% show_sub_menu 1 %}
</ul>

Rooted at level 0:

<ul>
    {% show_sub_menu 1 0 %}
</ul>

Or with a custom template:

<ul>
    {% show_sub_menu 1 None 100 "myapp/submenu.html" %}
</ul>

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:

<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¶

{{ node.is_leaf_node }}

Is it the last in the tree? If true it doesn’t have any children.

{{ node.level }}

The level of the node. Starts at 0.

{{ node.menu_level }}

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.

{{ node.title }}

The title in the current language of the node.

{{ node.selected }}

If true this node is the current one selected/active at this URL.

{{ node.ancestor }}

If true this node is an ancestor of the current selected node.

{{ node.sibling }}

If true this node is a sibling of the current selected node.

{{ node.descendant }}

If true this node is a descendant of the current selected node.

{{ node.soft_root }}

If true this node is a soft root. A page can be marked as a soft root in its ‘Advanced Settings’.

Modifying & Extending the menu¶

Please refer to the How to customise navigation menus documentation

Menu system classes and function¶

menu application¶

class menus.base.Menu¶

The base class for all menu-generating classes.

get_nodes(self, request)¶

Each sub-class of Menu should return a list of NavigationNode instances.

class menus.base.Modifier¶

The base class for all menu-modifying classes. A modifier add, removes or changes NavigationNodes in the list.

modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb)¶

Each sub-class of Modifier should implement a modify() method.

class menus.menu_pool.MenuPool¶
get_nodes()¶
discover_menus()¶
apply_modifiers()¶
_build_nodes()¶
_mark_selected()¶
menus.menu_pool._build_nodes_inner_for_one_menu()¶
menus.templatetags.menu_tags.cut_levels()¶
class menus.templatetags.menu_tags.ShowMenu¶
get_context()¶
class menus.base.NavigationNode(title, url, id[, parent_id=None][, parent_namespace=None][, attr=None][, visible=True])¶

Each node in a menu tree is represented by a NavigationNode instance.

Parameters
  • title (str) – The title to display this menu item with.

  • url (str) – The URL associated with this menu item.

  • id – Unique (for the current tree) ID of this item.

  • parent_id – Optional, ID of the parent item.

  • parent_namespace – Optional, namespace of the parent.

  • attr (dict) – Optional, dictionary of additional information to store on this node.

  • visible (bool) – Optional, defaults to True, whether this item is visible or not.

attr¶

A dictionary, provided in order that arbitrary attributes may be added to the node - placing them directly on the node itself could cause a clash with an existing or future attribute.

An important key in this dictionary is is_page: if True, the node represents a django CMS Page object.

Nodes that represent CMS pages have the following keys in attr:

  • auth_required (bool) – is authentication required to access this page

  • is_page (bool) – Always True

  • navigation_extenders (list) – navigation extenders connected to this node

  • redirect_url (str) – redirect URL of page (if any)

  • reverse_id (str) – unique identifier for the page

  • soft_root (bool) – whether page is a soft root

  • visible_for_authenticated (bool) – visible for authenticated users

  • visible_for_anonymous (bool) – visible for anonymous users

get_descendants()¶

Returns a list of all children beneath the current menu item.

get_ancestors()¶

Returns a list of all parent items, excluding the current menu item.

get_absolute_url()¶

Utility method to return the URL associated with this menu item, primarily to follow naming convention asserted by Django.

get_menu_title()¶

Utility method to return the associated title, using the same naming convention used by cms.models.Page.

class menus.modifiers.Marker¶
class menus.modifiers.AuthVisibility¶
class menus.modifiers.Level¶
mark_levels()¶

cms application¶

class cms.menu.CMSMenu¶

Subclass of menus.base.Menu. Its get_nodes() creates a list of NavigationNodes based on Page objects.

class cms.menu.NavExtender¶
class cms.menu.SoftRootCutter¶
class cms.menu_bases.CMSAttachMenu¶

© Copyright 2009-2021, Divio AG and contributors. Revision 4012e392.

Edit on GitHub

Documentation v: latest
Versions
latest
release-4.0.x
release-3.8.x
release-3.7.x
release-3.6.x
release-3.5.x
release-3.4.x
release-3.3.x
release-3.2.x
release-3.1.x
release-3.0.x
release-2.4.x
release-2.3.x
release-2.2.x
release-2.1.x
develop
Downloads
pdf
epub