Re: variable assign in Smarty

From: Date: Tue, 26 Mar 2002 20:48:10 +0000
Subject: Re: variable assign in Smarty
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3374@lists.php.net to get a copy of this message
Christophe Ruelle wrote: > > Hi everybody, > > Is there a way to assign variables inside a template ? yes, with the {assign ...} plugin function. > ---- the way I would like to do it : > > {if $name == "bill" $class="class1" elseif $name == "john" > $class="class2" > else $class="class3" /if} // syntax is bad - juste an idea That syntax won't happen, but if you're looking for some kind of syntax short cut, you could write a custom function or modifier to handle it. example: <td {$name|case:"bill;john;default":"class1;class2;class3"}> The above example has the limitation that none of the values can have a semicolon. But you can make it as simple/complex as you like ;-) Monte

« previous php.smarty.general (#3374) next »