Forum template tags
Board / TemplateTagsThis documentation explains the templatetags provided by the Board application.
You need to {% load sphboard_extras %} to use them.
1. Display all available categories
It might be useful to display a hierarchical list of the forum categories - e.g. for a "jump to forum" select box or similar. This can be done using the sphboard_recursive_category_iterator template tag.
1.1. Usage
The content between sphboard_recursive_category_iterator and endsphboard_recursive_category_iterator will be taken and rendered for every category in the hierarchy. In each iteration the context will be filled with the following template variables:
- category: the current Category object.
- children: the rendered children of this category (if you do not include this in your template, only the root categories will be rendered)
- depth: an integer representing the current depth in the hierarchy (starting with 0)
- depthrange: can be used in a for loop, for example to display "-" for every step in the hierarchy.
1.2. Example
The following example displays a simple select box which will jump to the selected forum as soon as the value is changed.
{% load sphboard_extras %}
<select name="category" onchange="if(this.value) document.location = this.value;" class="sphboard_selectcategory">
<option value="">Jump to category</option>
<option value="">------------------</option>
{% sphboard_recursive_category_iterator %}
<option value="{{ category.get_absolute_url }}">{% for i in depthrange %}--{% endfor %} {{ category.name }}</option>
{{ children }}
{% endsphboard_recursive_category_iterator %}
</select>
Tags:
Last Modified: 2008-04-12 17:07:43 by Herbert Poul - [ Snip Changes ] [ Wiki History ]

0 Comments
No comments yet.
Post New Thread