1.4.3.4. Template variables

About the most important data type for the template language is the template variable. Template variables are used by Phorum to store dynamic data, which can be used by your templates. You can also use the variables for storing dynamic data of your own from the templates. Template variables can contain both simple values and complex arrays of data.

You can reference a template variable by using the variable's name, without any quotes.

Note

This is the same type of notation as the one that is used for referencing PHP constants (see Section 1.4.3.3, “PHP constants”). If there are both a constant and a variable with the same name, the value of the contstant will take precedence over the template variable.

Example 1.10. Template variables

NAME
HTML_TITLE
MESSAGES


In case the variable represents an array, you can reference the array elements by using the following pointer notation:

Example 1.11. Referencing elements in a template variable array

ARRAYVARIABLE->SIMPLE_ELEMENT
ARRAYVARIABLE->ARRAY_ELEMENT->SIMPLE_ELEMENT


Within a template, variables are used like this:

Example 1.12. Code using template variables

{VAR MY_VAR "Assign a value to a variable from the template"}

You username is: {USER->username}<br/>
The current forum's name is: {NAME}<br/>

{LOOP MESSAGES}
  Subject: {MESSAGES->subject}<br/>
{/LOOP MESSAGES} 


What variables are available for what template pages is fully determined by Phorum.