Mar 13, 2018 18:30:43 GMT -5 |
Post by madie on Mar 13, 2018 18:30:43 GMT -5
Link to original!
There's, unfortunately, no documentation on how these work, but they pretty much work the same as in most web languages and share the same operators.
{if} / {/if}
HTML within an if statement only renders on the page if the if statement validates as true.
{elseif}
An elseif statement gives an if statement another condition to check against if the first statement rendered as false and renders its own HTML if that condition is met.
{else}
An else statement gives an if statement a final set of HTML to render if none of the previous conditions were met.
{foreach} / {/foreach}
A foreach loop can go through certain variables and output HTML based on the various properties within that variable. You can determine which variables can be looped through based on whether or not they contain an index property when expanded in the Loops and Variables tree to the right of the template you're editing.
There's, unfortunately, no documentation on how these work, but they pretty much work the same as in most web languages and share the same operators.
{if} / {/if}
HTML within an if statement only renders on the page if the if statement validates as true.
{if $[current_user.is_staff]}
You're a member of a group that's considered forum staff!
This if statement rendered as true because the staff variable outputs the value "1" (true).
If you weren't staff it would output "0" (false), failing the if statement.
{/if}
{if $[current_user.gender.text] == "Male"}
Hey, dude!
This if statement rendered as true because your gender text is Male. (==)
{/if}
{if $[current_user.id] != 1}
Hey... you're not the main admin!
This if statement rendered as true because your user ID is not 1. (!=)
{/if}
{if !$[current_user.group]}
You're not in a group!
This if statement rendered as true because the variable either didn't return
a true value or didn't return any value. (!$[variable])
{/if}
{if $[user.is_staff] && $[user.is_online]}
This person if a staff member! AND (&&) they're online!
This if statement rendered as true because both variables returned "1" (true).
{/if}
{if $[user.is_banned] || $[user.is_deleted]}
This is a banned user OR (||) a deleted user.
This if statement rendered as true because one of the variables returned "1" (true).
{/if}
An elseif statement gives an if statement another condition to check against if the first statement rendered as false and renders its own HTML if that condition is met.
{if $[current_user.is_staff]}
Greetings, your highness.
{elseif $[current_user.is_member]}
Good morrow to thee, fellow citizen!
{/if}
An else statement gives an if statement a final set of HTML to render if none of the previous conditions were met.
{if $[current_user.is_staff]}
Greetings, your highness.
{elseif $[current_user.is_member]}
Good morrow to thee, fellow citizen!
{else}
Hail, traveler! Is this your first time in our kingdom?
{/if}
A foreach loop can go through certain variables and output HTML based on the various properties within that variable. You can determine which variables can be looped through based on whether or not they contain an index property when expanded in the Loops and Variables tree to the right of the template you're editing.
The following is a numerical list of each of our forum's categories:
<br><br>
{foreach $[category]}
<div>$[category.iteration]. $[category.name]</div>
{/foreach}