Documentation / Documentation for web designers / RainTPL Tags 

{if="condition"}{/if}

{if} tag is the equivalent of php if statement. Into the {if} condition you can use variables tags without delimiters "{", "}", and you can also use PHP code.

Example:

<!-- year = 29 -->
{if="$year > 18"}major{/if}
{if="$year > 18"}major{else}not major{/if}
{if="$year < 20"}less than 20 years{elseif="$year < 30"}less than 30 years{/if}

<!-- isLogged() return true if user is logged -->
{if="isLogged()"}Hello {$name}{else}Not Logged{/if}


Output:

major
major
less than 30 years

Hello Rain



In certain situation could be easier to use the ?: operator

{$is_logged? 'Hello $name':'Not logged'}

 

« {#constant#} ^ RainTPL Tags ^ {loop="array"}{/loop} »

Documentation for web designers




Documentation for PHP developers