Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Largest classified with thousands of ads at Shoppok

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Find Wedding Dresses Online at Canada from Ca-dresses.com

Find your local domestic cleaner

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Advertisement

if,elseif,else

Los comandos {if} del Smarty tiene mucho de la flexibilidad del comando if de php, con algunas adiciones para la herramienta de template. Todo {if} debe tener su {/if}. {else} y {elseif} también son permitidos. Toda las condicionales de PHP son reconcidas, tal como ||, or, &&, and, etc.

La siguiente es una lista de calificadores reconocidos, los cuales deberan estar separados los dos elementos por espacios. Nota loas articulos pueden listarse [entre corchetes] es opcional. Equivalentes al lugar donde se apliquen en PHP.

Calificador Alternativa Ejemplo de Sintaxis Significado Equivalente en PHP
== eq $a eq $b Iguales ==
!= ne, neq $a neq $b Diferentes !=
> gt $a gt $b Mayor que >
< lt $a lt $b menor que <
>= gte, ge $a ge $b mayor que o igual >=
<= lte, le $a le $b menor que o igual <=
===   $a === 0 Igual e indentico ===
! not not $a negación (unary) !
% mod $a mod $b modulo %
is [not] div by   $a is not div by 4 divisible por $a % $b == 0
is [not] even   $a is not even [not] es numero par (unary) $a % 2 == 0
is [not] even by   $a is not even by $b agrupar niveles pares [not] ($a / $b) % 2 == 0
is [not] odd   $a is not odd [not] el numero es impar (unary) $a % 2 != 0
is [not] odd by   $a is not odd by $b [not] agrupa los niveles impares ($a / $b) % 2 != 0

Example 7.13. sentencia if


{if $name eq "Fred"}
	Welcome Sir.
{elseif $name eq "Wilma"}
	Welcome Ma'am.
{else}
	Welcome, whatever you are.
{/if}

{* Un ejemplo con "or" logico *}
{if $name eq "Fred" or $name eq "Wilma"}
	...
{/if}

{* El mismo que arriba *}
{if $name == "Fred" || $name == "Wilma"}
	...
{/if}

{* La siguiente sintaxis no funcionara, el calificador de condición
   deben estar separados entre ellos por espacios *}
{if $name=="Fred" || $name=="Wilma"}
	...
{/if}


{* los parentesis son permitidos *}
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
	...
{/if}

{* Usted también puede colocar funciones de PHP *}
{if count($var) gt 0}
	...
{/if}

{* checa si el valor es par o impar *}
{if $var is even}
	...
{/if}
{if $var is odd}
	...
{/if}
{if $var is not odd}
	...
{/if}

{* checa si la variable  var es divisible por 4 *}
{if $var is div by 4}
	...
{/if}

{* Checa si la variable var es igual, agrupandola por dos. 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}


Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 6 plus 2? (Are you human?)

Advertisement

Sponsors [info]

UK Web Hosting @webhost.uk.net
Best Web Hosting @rshosting.com
Web Hosting UK @webhostinguk.com
Unlimited Web Hosting @infrenion.com
App Entwicklung @morphodo.com
First Click Internet Marketing @fcinternetmarketing.com
Credit Card Processing Company