Identifying and using variables in templates, advertising positions, navigation entries, and widgets

Identifying and using variables in templates, advertising positions, navigation entries, and widgets

Brogan

XenForo moderator
Staff member
Brogan submitted a new resource:

Identifying and using variables in templates, advertising positions, navigation entries, and widgets - $xf.bro_guide

What are variables?​

In simple terms, variables are names which hold values.
These values are stored in the database and are used in templates to evaluate and present the content and data.

Using variables in templates opens up a lot of possibilities for customising and modifying the look and behaviour of an XF installation.

Read more about this resource...
 

Brogan

XenForo moderator
Staff member
Brogan updated Identifying and using variables in templates, advertising positions, navigation entries, and widgets with a new update entry:

Passing values to the container

A useful function is being able to pass variables from a template to the container, so they are available globally.

Take the thread ID for example, that typically isn't available outside the thread_view template.

We can make it available elsewhere by adding this to the thread_view template:
HTML:
<xf:page option="threadID">{$thread.thread_id}</xf:page>

What that code does is take the thread ID value from $thread.thread_id and assign...

Read the rest of this update entry...
 

Brogan

XenForo moderator
Staff member
Brogan updated Identifying and using variables in templates, advertising positions, navigation entries, and widgets with a new update entry:

Conditional statement syntax

We've already discussed how varaiables are used in conditional statements.

However, there is a difference in the syntax used for templates and advertising positions, and navigation and widget display conditions.


In templates and advertising positions, the syntax takes this form for true:
HTML:
<xf:if is="$var">
HTML:
<xf:if is="$var == 'thing'">
HTML:
<xf:if is="in_array($var, ['thing', 'other_thing'])">

And this form for false:
HTML:
<xf:if...

Read the rest of this update entry...
 

Stuart Wright

Well-known member
$xf.visitor.signature used to work in a page type node. Doesn't any more. Know how to get the viewing member's signature?
 
Top