Re: 'default' modifier
| From: | Monte Ohrt | Date: | Wed, 13 Jun 2001 14:42:22 +0000 |
| Subject: | Re: 'default' modifier | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-883@lists.php.net to get a copy of this message | ||
I'm adding an assign function to Smarty for assigning vars during the
execution of a template:
{assign var="foo" val="bar"}
This could be used for what you are looking for, by putting this at the
top of the template:
{assign var=$foo val=$foo|default:"blah"}
This would set $foo to the default value if $foo is empty.
Mike Krus wrote:
>
> Andrei Zmievski wrote:
>
> > We'll take a look at this suggestion.
> This is not related to the previous request, it might be a good idea also
>
> to have a function to set a default value for a variable within the
> template.
>
> I know you can do {$foo|default:"bar"} but if you use $foo often
> it get ugly. It also does not seem to work well in control structures...
>
> Being able to do {setdefault name=foo value="bar"} would assign the
> value to $foo if it was unset or empty, and do nothing otherwise...
>
> Mike
>
> ---
> 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/