Conditional Statements

Conditional Statements

Paul B

XenForo moderator
Staff member
Brogan submitted a new resource:

Conditional Statements - Guide and tutorial for conditional statements using XenForo syntax

Conditionals

The following conditional statements will only work in templates which support the arguments and parameters.

Statements can be expanded using AND, OR, and <xen:else />.

Replacing == with != in the following examples will change the condition from true to false.
For example, <xen:if is="{$visitor.user_id} == x"> for true, <xen:if is="{$visitor.user_id}...

Read more about this resource...
 
Thank you for posting this as a resource. I hunt down your FAQ thread just to jump to the conditional statements tutorial at least once a month cause something always comes up to where I'll need it. I even bookmarked that thread at one point. Posting this as a resource will make this a lot easier to find, thank you.
 
What is the meaning of the percentage in this conditional:
Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x AND !{$message.conversation_id}">
This content will show after post x on every page in a thread
</xen:if>
Is it the modulus operator or something else ?
 
Thanks for this resource, @Brogan. If I only wanted to show a button to a user on their own personal details page (it's going to be an edit button), how do I condition everyone out except for the user?
 
Brogan updated Conditional Statements with a new update entry:

Making the category ID available for use in the ad_ templates

If you have pages set for categories (ACP -> Options -> Node & Forum List) you may want to utilise the category ID in the ad_ templates, to prevent ad's being shown in certain categories for example.

To do so, edit the category_view template and add the following at the top:
HTML:
<xen:container var="$category.node_id">{$category.node_id}</xen:container>

That will ensure the category ID is available for use in the ad_ templates, allowing you to use the category node ID conditional as...

Read the rest of this update entry...
 
I would like to show content under the sticky post but only on the first page of a forum.

Anybody know how do I prevent the content from showing on page 2, 3 etc.?
 
How many sticky threads do you have?

Most forums usually only have a few so the ad_thread_list_below_stickies will work for that.
 
Top Bottom