Re: Some ways to improve it?
| From: | Monte Ohrt | Date: | Wed, 05 Dec 2001 19:19:10 +0000 |
| Subject: | Re: Some ways to improve it? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2152@lists.php.net to get a copy of this message | ||
What Andrei pointed out will do what you want:
{assign var="last" value=$smarty.get.last|default:0}
This will assign $smarty.get.last to $last, unless $smarty.get.last is
empty, then "0" is assigned. Do you even need to introduce the $last
variable?
{$smarty.get.last|default:0}
Ricard Pillosu wrote:
>
> I'll answer myself ... one way I just discovered is simply:
>
> {assign var="last" value=0}
> {assign var="last" value=$smarty.get.last}
>
> But it is not so clear to read ...
>
> El mié, 05-12-2001 a las 18:09, Ricard Pillosu escribió:
> > Just wondering how to improve something like this:
> >
> > {if $smarty.get.last == ""}
> > {assign var="last" value="0"}
> > {else}
> > {assign var="last" value=$smarty.get.last}
> > {/if}
> >
> > code explains itself ...
>
> --
> Ricard Pillosu González
> New Tech. Software Engineer
> Dorna Sports, S.L.
> ricardpillosu@dorna.es
> http://www.motograndprix.com
> Tel. +34 934702865
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/