Hagai
OMG Member
- Joined
- Oct 9, 2010
- Messages
- 207
The xenForo template Syntax guide
written by Hagai for xenFans
The xenForo template system is very unique.
This guide was written for you to get basic knowledge of the template syntax.
Lets start shall we?
Every xenForo template function starts with xen:.
For example: {xen:link}
written by Hagai for xenFans
The xenForo template system is very unique.
This guide was written for you to get basic knowledge of the template syntax.
Lets start shall we?
Every xenForo template function starts with xen:.
For example: {xen:link}
- “<xen:require />”
this function as the following attributes: <type>=”<location>”.
This function is the same function as “require_once(<location>);” in PHP.
The type can be: css/js(in lowercase). And the <location> at CSS type is the CSS template name.
Every require must end with “/>”. - "<xen:include />”
this function as the sane attributes of the require function.
But, the her type can be only “template” and the location is the template name
The big difference between require and include is that in include you can and may declare the template variable!
For example:HTML:<xen:include template=”myTemplate”><xen:set var=”$myTemplateVar”>myTemplateVarValue</xen:set> </xen:include>
- "<xen
et></xen
et>”
The function is the function we use to declare a variable in a template.
Her usage is: <xenet var=”$<varname>”><varvalue></xen
et>.
The Variable name must apply to the conditions of the php variable name.PHP:$$varname = not good! $_VarName = good :)
et>” must end with “</xen
et>”
- "<xen:if>{<xen:else />}</xen:if>”.
The “<xen:else />” property is only optional.
The “<xen:if>” syntax is:HTML:<xen:if <type>=”<condition>”> true statments { <xen:else /> false statments } </xen:if>
The type can be: hasconent(I will explain later) and is.
The usage of is:HTML:<xen:if is=”{$variable)”> the variable “variable” is exist <xen:else /> The variable “variable doesn't exist </xen:if>
- "<xen:foreach></xen:foreach>”
The “<xen:foreach>” is the equivalent of the foreach loop in PHP. Her attributes are:
loop, and value. Loop is the similar as “$foo” in the php foreach and the value is the item in the php foreach. Example:HTML:<xen:foreach loop="$foo" value="$item"> statment block </xen:foreach>
PHP:foreach( $foo as $item ) { statment block }
- The variables in xF templates.
In order to output the value of an variable we useHTML:{$<varname>}. If the variable is an 1-D array we use: [code=html]{$<arrayname>.<arrayitem>}
- Displaying phrases, in order to output an phrase we are using the
HTML:
{xen:phrase <phrasevarname>}
I've just created a phrase that is text is: “Hello World!” and is varname is “hello_world”, In order to output him I will useHTML:{xen:phrase hello_world}
- "<xen:title></xen:title>”
the “<xen:title>” function determins the “Ttitle” of the page. By saying title I mean:
The thing is yellow marked is the “title” to set your own title you can use:
HTML:<xen:title>My new title</xen:title>
- The security token. XF programers created an automaticly secuirity token to handle “CSRF” attacks. To use this “security token” in your template use the next expression:
HTML:{$visitor.csrf_token_page}
If you are creating your own form you must add the next line to avoid errors:
HTML:<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />