EQ equals,
NE, neq not Equal,
GT greater Than,
LT is less than
GTE, GE greater than equals,
LTE, le less than equals,
Not non, mod modulo.
Is (not) div by can be divisible by a number,
is [not]even whether an even number,
$a is [not] even by $b i.e. ($a/$b)% 2 = = 0,
Is (not) odd is odd,
$a is a odd by $b ($a/$b)% 2! = 0 Example:
Equal/not Equal/greater than/less than/less than or equal/great than or equal/it's needless to say.
The IF statement in the Smarty andPHPis as flexible and easy to use as the IF statement, and adds several features to fit the template engine. The if must appear in pairs of/if. You can use the else and elseif clauses. You can use the following conditional modifiers: EQ, NE, neq, GT, LT, LTE, Le, GTE, GE, is even, is odd, is noteven, is not odd, not, MoD, div by, even By, oddby, = =,! =, >, <, <=, >=. When you use these modifiers, you must and the variable or constant are opened with an empty space.
Example 7-11. If statements
Example 7-11. If statement demo
{if $name eq "Fred"}
Welcome Sir.
{elseif $name eq "Wilma"}
Welcome Ma ' am.
{Else}
Welcome, whatever.
{/if}
{* An example with "or" logic *}
{if $name eq "Fred" or $name eq "Wilma"}
...
{/if}
{* Same as above *}
{if $name = = "Fred" | | $name = = "Wilma"}
...
{/if}
{* The following syntax won't work, conditional qualifiers
Must is separated from surrounding elements by spaces *}
{if $name = = "Fred" | | $name = = "Wilma"}
...
{/if}
{* Parenthesis is allowed *}
{if ($amount < 0 or $amount >) and $volume >= #minVolAmt #}
...
{/if}
{* You can also embed PHP function calls *}
{if count ($var) GT 0}
...
{/if}
{* Test if values are even or odd *}
{if $var is even}
...
{/if}
{if $var is odd}
...
{/if}
{If $var is not odd}
...
{/if}
{* Test if VAR is divisible by 4 *}
{if $var is div by 4}
...
{/if}
{* Test if Var is even, grouped by. i.e.,
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc. *}
{If $var is even by 2}
...
{/if}
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
{If $var is even by 3}
...
EQ equals, smarty comparison operator!