This reusable Django app introduces site tree, menu and breadcrumbs navigation elements
Project description
http://github.com/idlesign/django-sitetree
What’s that
django-sitetree is a reusable application for Django, introducing site tree, menu and breadcrumbs navigation elements.
Site structure in django-sitetree is described through Django admin interface in a so called site trees. Every item of such a tree describes a page or a set of pages through the relation of URI or URL to human-friendly title. Eg. using site tree editor in Django admin:
URI Title / - Site Root |_users/ - Site Users |_users/13/ - Definite User
Alas the example above makes a little sense if you have more than just a few users, that’s why django-sitetree supports Django template tags in item titles and Django named URLs in item URIs. If we define a named URL for user personal page in urls.py, for example, ‘users-personal’, we could change a scheme in the following way:
URI Title / - Site Root |_users/ - Site Users |_users-personal user.id - User Called {{ user.first_name }}
After setting up site structure as a sitetree you should be able to use convenient and highly customizable site navigation means (menus, breadcrumbs and full site trees).
Requirements
Django 1.1+
Admin site Django contrib package
How to use
Add the ‘sitetree’ application to ‘INSTALLED_APPS’ in your settings file (usually ‘settings.py’).
Run ‘./manage.py syncdb’ to install sitetree tables into database.
Go to Django Admin site and add some trees and tree items (Detailed instruction at StackOverflow).
Add ‘{% load sitetree %}’ tag to the top of a template.
Now you can use the following template tags:
‘sitetree_menu’ tag renders menu based on sitetree:
{% sitetree_menu from "mytree" include "trunk" %}
‘sitetree_breadcrumbs’ tag renders breadcrumbs path based on sitetree:
{% sitetree_breadcrumbs from "mytree" %}
‘sitetree_tree’ tag renders entire site tree:
{% sitetree_tree from "mytree" %}
‘sitetree_page_title’ tag renders page title resolved against definite sitetree:
{% sitetree_page_title from "mytree" %}
Overriding sitetree built-in templates
To customize navigation elements view you should override the built-in sitetree templates as follows:
Switch to sitetree folder
Switch further to ‘templates/sitetree’
There you’ll find the following templates:
breadcrumbs.html
menu.html
tree.html
Copy whichever of them you need into your project templates directory and feel free to customize it.
See ‘Notes on advanced sitetree tags’ below for clarification on two advanced sitetree template tags.
Translating django-sitetree
You can translate application into your language if it is supported by Django.
For translation tips refer to Django documentation: http://docs.djangoproject.com/en/1.1/topics/i18n/localization/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.