For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > May 2006 > New "set" plugin









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author New "set" plugin
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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com