Sphene Community Tools

Community

Copyright © 2007-2018 by Herbert Poul

You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools

Forum template tags

Board / TemplateTags

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

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>

2. Display the latest threads of one category

You probably want to list the latest threads of a category e.g. on the start page or in the base template on one side of your website (something like 'latest news', etc.) - If you are not using the Wiki, this template tag is for you.

2.1. Usage

Simply pass in the ID for the category for which you want to display the latest threads. You probably want to use a settings variable for this, so you don't have a hardcoded ID in your templates. (but feel free to do it any other way)

2.2. Example

        {% load sphboard_extras %}
        {% sphboard_latest_threads sph_settings.groups_sphene_news_category_id %}
          {% for post in threads %}
            <h2>{{ post.postdate|sph_date:"ONLY_DATE" }}</h2>
            <p><a href="{{ post.get_absolute_url }}">{{ post.subject }}</a></p>
            <p>{{ post.body_escaped }}</p>
          {% endfor %}
        {% endsphboard_latest_threads %}

Tags:

Last Modified: 2009-08-13 23:01:34 by Herbert Poul - [ Snip Changes ] [ Wiki History ]

0 Comments

No comments yet.

Please login to create a new thread.



Powered by Sphene Community Tools