if,elseif,else Comandos {if} no Smarty tem muito da mesma flexibilidade do php, com algumas características à mais para o sistema de template. Todo if deve ter o seu /if. else e elseif também são permitidos. Todos os condicionais do PHP são reconhecidos, tais como ||, or, &&, and, etc. A seguir está uma lsita dos qualificadores, que devem estar separados dos elementos por espaço. Note que itens listado entre [conchetes] são opcionais. Os equivalentes em PHP são mostrados quando aplicáveis. Qualificador Alternativas Exemplo de sintaxe Significado Equivalente no PHP == eq $a eq $b iguais == != ne, neq $a neq $b não iguais != > gt $a gt $b maior que > < lt $a lt $b menor que < >= gte, ge $a ge $b maior ou igual à >= <= lte, le $a le $b menor ou igual à <= ! not not $a negação (unary) ! % mod $a mod $b módulo % is [not] div by $a is not div by 4 divisível por $a % $b == 0 is [not] even $a is not even [not] an even number (unary) $a % 2 == 0 is [not] even by $a is not even by $b grouping level [not] even ($a / $b) % 2 == 0 is [not] odd $a is not odd [not] an odd number (unary) $a % 2 != 0 is [not] odd by $a is not odd by $b [not] an odd grouping ($a / $b) % 2 != 0 comandos if 1000 ) and $volume >= #minVolAmt#} ... {/if} {* você pode também colocar funções php *} {if count($var) gt 0} ... {/if} {* testa se o valor é par ou impar *} {if $var is even} ... {/if} {if $var is odd} ... {/if} {if $var is not odd} ... {/if} {* verifica se a variável é divisível por 4 *} {if $var is div by 4} ... {/if} {* test if var is even, grouped by two. 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} ... {/if} ]]>