| Davide [Design] Muzzarelli 2006-05-16, 7:13 pm |
| I've created a new function that set or assign a value to a variable.
It work also with and can create simple arrays!
The optional parameter "if" is used to set the value if the test is true. The
test can
be: 'empty', '!empty', 'is_null', '!is_null', 'isset', '!isset', 'is_void'.
The new command 'is_void' test if the variable is empty and != 0, very useful
for test $_REQUEST parameters.
See and download from:
http://smarty.incutio.com/?page=set
- - -
Example, create a new variable like "assign" plugin:
{set var=$foo value="bar"}
Example, create a new blank variable like "setvar" plugin:
{set var=$foo}
Example, create a new blank array:
{set var=$foo.bar}
Example, create a new array item:
{* $foo is an array or do not exist *}
{set var=$foo.bar value=true}
Example, change a variable value only if it is null (great for $_REQUEST
variables):
{* $foo is a null variable *}
{set var=$foo value="bar" if=is_null}
--
Davide "Design" Muzzarelli
www . dav - muz . net
www. fraw . info - a PHP framework with Smarty
|