Template tags¶
To use template tags available in SiteTree you should add {% load sitetree %} tag to the top of chosen template.
Tree tag argument (part in double quotes, following from word) of SiteTree tags should contain the tree alias.
Hint
-
Tree tag argument could be a template variable (do not use quotes for those).
-
Optional
templateargument could be supplied to all SitetTree tags except sitetree_page_title to render using different templates. It should contain path to template file.
sitetree_menu¶
This tag renders menu based on sitetree.
Example
This command renders as a menu sitetree items from tree named mytree, including items under trunk and topmenu aliased items.
That means that trunk and topmenu themselves won't appear in a menu, but rather all their ancestors.
Hint
If you need item filtering behaviour consider using a customized tree handler.
Aliases are given to items through Django's admin site.
Reserved aliases¶
Note that there are some reserved aliases. To illustrate how do they work, take a look at the sample tree:
Note
As it mentioned above, basic built-in templates won't limit the depth of rendered tree, if you need to render the limited number of levels, you ought to override the built-in templates. For brevity rendering examples below will show only top levels rendered for each alias.
trunk¶
Get hierarchy under trunk, i.e. root item(s) - items without parents:
this-children¶
Get items under item resolved as current for the current page.
Considering that we are now at Articles renders:
this-siblings¶
Get items under parent of item resolved as current for the current page (current item included).
Considering that we are now at Bad renders:
this-parent-siblings¶
Items under parent item for the item resolved as current for the current page.
Considering that we are now at Public renders::
this-ancestor-children¶
Items under grandparent item (closest to root) for the item resolved as current for the current page.
Considering that we are now at Public renders all items under Home (which is closest to the root).
Thus, in the template tag example above trunk is reserved alias, and topmenu alias is given to an item through the admin site.
Note
Sitetree items could be addressed not only by aliases but also by IDs::
Example
sitetree_breadcrumbs¶
This tag renders breadcrumbs path (from tree root to current page) based on sitetree.
Example
This command renders breadcrumbs from tree named mytree.
sitetree_tree¶
This tag renders entire site tree.
Example
This command renders sitetree from tree named mytree.
sitetree_page_title¶
This tag renders current page title resolved against definite sitetree. The title is taken from a sitetree item title resolved as current for the current page.
Example
This command renders current page title from tree named mytree.
sitetree_page_description¶
This tag renders current page description resolved against definite sitetree. The description is taken from a sitetree item description resolved as current for the current page.
That can be useful for meta description for an HTML page.
Example
This command renders current page description from tree named mytree.
sitetree_page_hint¶
This tag is similar to sitetree_page_description, but it uses data from
tree item hint field instead of a description fields.
Example
Settings¶
SITETREE_RAISE_ITEMS_ERRORS_ON_DEBUG¶
DEFAULT: True
There are some rare occasions when you want to turn off errors that are thrown by sitetree even during debug.
Setting SITETREE_RAISE_ITEMS_ERRORS_ON_DEBUG = False will turn them off.