iGeek Blog

Jignesh Patel's Blog

categories

recent posts

recent comments



Its simple and sober to assign value to a variable in Smarty. However assign an array to a variable in .tpl file is not simply available. You can create ab array in PHP and assign it to the variable to be used in smarty template, but its on PHP side.

But what if you want to do something like this ?

{assign var=$col_width value=array('2%','10%','17%','13%','20%','10%','19%')}

No, we cant do that. For doing the same thing you have to put a compiler.set.php file inside smarty directory. Can be downloaded from here : http://smarty.incutio.com/?page=set
Put it here: smarty/libs/plugins

To create array use the syntax below:

{set var=$col_width value=array('2%','10%','17%','13%','20%','10%','19%')}

0 comments

Post a Comment