Templating reference
An advice before you start writing templates
Enable the debugmode of Ratatöskr. Login to the backend of your Ratatöskr installation and go to Administration > Settings and toggle the debugmode value to "enabled". After this, Ratatöskr will print out error messages, if you messed up your templates and will therefore make writing templates much easier.
Representations of different data in templates
Representation of an article
An article is represented as an array with these fields:
id
– The database ID of the article.urlname
– The URL name of the articlefullurl
– The full URL to the articletitle
– The title (HTML)text
– The full text of the article (HTML)excerpt
– The excerpt of the article (HTML)custom
– At the moment not used.status
– The numeric status of the article. 1: Live; 2:Stickysection
– Informations about the current section (see Representation of a section)timestamp
– The timestamp as a unix timestamp. Use STE'sste:date
tag to transform this into something human readable.tags
– An array of tags. See Representation of a tag.languages
– An array that holds infomation about languages, in which this article is availabe at. The array keys are the language code (e.g. en, de, it, ...), the value is a URL to thie article in this language.comments_allowed
– Is empty, if comments are not allowed, otherwise this is not empty.
Representation of a section
A section is represented as an array with these fields:
id
– The database ID of the section.name
– The name of the section.title
– The title of the section in the current language.
Representation of a tag
A tag is represented as an array with these fields:
id
– The database ID of the tag.name
– The name of the tag.title
– The title of the tag in the current language.
Representation of a comment
A comment is represented as an array with these fields:
id
– The database ID of the article.text
– The text of the article (HTML).author
– The autors name (HTML).timestamp
– The unix timestamp of this article. Use STE'sste:date
tag to transform this into something human readable.
Variables
$current
Holds information about the currently displayed page.
Fields of $current:
article
– Only set if a single article is shown (Useste:if
to detect this). Holds information about an article. (see Representation of an article).section
– Only set if a whole section is shown (Useste:if
to detect this). Holds information about an section. (see Representation of a section).tag
- Only set if all articles with the same tag should be shown (pseudo section _tags; useste:if
to detect this). Holds information about a tag. (See Representation of a tag).page
– Which subpage is shown? Useful with pageprev, pagenext and the page parameter of articles_get. Default: 1commented
– Non-empty, if the visitor has successfully written a comment.comment_fail
– If the user tried to comment, but the system rejected the comment, this will be set and will contain the error message.comment_prev
– If the user wanted to preview the article, this will be set and contain the HTML code of the comment.styles
– The styles, that should be loaded. You can also just use ste:styles_load.url_fragments
– Array of URL parts. Mainly used internally, so you really should not modify this one...oldcomment
– The data of the previously sent formular (subfields: name, mail, text). Only set inside the ste:comment_form tag.
Plugins might insert their own fields.
$language
The short form of the current language (e.g. "en", "de", "it", ...)
Tags
ste:articles_get
This tag will get all articles that match the passed criterias and will run it's content for every article.
Parameters:
var
– (mandatory) The name of the variable, where the current article should be stored at. This variable will then be an array (see Representation of an article)id
– (optional) Filter by ID.urlname
– (optional) Filter by urlname.section
– (optional) Filter by section (section name).status
– (optional) Filter by status (numeric, 1 means "live" and 2 means "sticky". Hidden articles will always be ignored).tag
– (optional) Filter by tag (tag name).sort
– (optional) How to sort. Format: "fieldname direction" where fieldname is one of [id, urlname, title, timestamp] and direction is one of [asc, desc].perpage
– (optional) How many articles should be shown per page (default unlimited). How to use paging will be described in the Paging tags section.page
– (optional) On which page are we (starting with 1). (Default: 1; see thepage
field of $current)maxpage
– (optional) (variable name) If given, the number of pages are stored in this variable.skip
– (optional) How many articles should be skipped? (Default: none)count
– (optional) How many articles to output. (Default unlimited)
ste:section_list
This tag will loop through all sections.
Parameters:
var
– (mandatory) The name of the variable, where the current section should be stored at. See Representation of a section.exclude
– (optional) Sections to exclude (comma seperated)include_default
– (optional) Should the default section be included? If yes, pass a non-empty text, otherwise a empty text. (default: No).
ste:article_comments_count
This tag will return the number of comments for a article.
Parameters:
article
– (mandatory) The name of the variable, where the article is stored at.
ste:article_comments
Loop through all comments for an article.
Parameters:
var
– (mandatory) The name of the variable, where the current comment should be stored at (see Representation af a comment).article
– (mandatory) The name of the variable, where the article is stored at.sort
– (optional) Should the comments be sorted chronologically (asc) or inverse (desc)? Default: asc
ste:comment_form
Generate a HTML form that allow the user to leave a comment for an article.
Parameters:
article
– (mandatory) The name of the variable, where the article is stored at.default
– (optional) If not empty, a default formular with the mandatory fields will be generated.
Tag Content:
If default
is not empty, the tag's content will be ignored and a default comment form will be generated. Otherwise you can define your own form content.
These form fields are mandatory:
<input type="text" name="author_name" />
– The Name of the author.<input type="text" name="author_mail" />
– The E-Mailaddress of the author(will never be published).<textarea name="comment_text"></textarea>
– The Text of the comment.<input type="submit" name="post_comment" />
– Submit button (thename
parameter is important).
Optionally, you can define this:
<input type="submit" name="preview_comment" />
– If this submit button was used, the comment will not be posted, but previewed
ste:page_prev and ste:page_next
These tags generate links to the previous (ste:page_prev
) / next (ste:page_next
) page of articles.
Parameters:
current
– (mandatory) The current page number (see thepage
field of $current).maxpage
– (mandatory) How many pages in total (see themaxpage
parameter of ste:articles_get)?default
– (optional) If empty, the tag's content will be used as the link's text, otherwise a default localized link text will be used.
ste:languages
Loops through all laguages available in the current context.
Parameters:
var
– (mandatory) The name of the variable, where the current language information should be stored at.
Fields of var:
short
– 2 letter code of language.fullname
– The full name of the language.url
– URL to the current page in this language.
ste:styles_load
Load all styles associated with the current section.
Parameters:
mode
– (optional) Either "embed" or "link". Default: link
ste:title
Generate a title
tag for the head section of your site that describes the currently viewed site.
The tag content should be the name of your site.link