Welcome Guest, Not a member yet? Register   Sign In
Pass array parameter in helper function within smarty template
#1

[eluser]Unknown[/eluser]
Hello,
i use smarty V3.0 to built templates in my app.I call helper functions in templates like that:
Code:
{helper_fun(func_parameter_1,func_parameter_2,..)}

In some helper functions is needed to pass a properties associative array as parameter.
e.g img function in html_helper :
Code:
$img_props = array(
          'src' => 'images/picture.jpg',
          'class' => 'img_class'.);
img($img_props);


I really don't want to define the properties array in my controller, then assign it to template and make the call like : {img($img_props)}

So, i'm looking for a way to define an associative array withing template, so i can do something like:
Code:
{assign img_props value=array('src'=>'images/img2.jpg','class'='some_class')}
{img ($img_props)}

or better:
Code:
{img(array('src'=>'images/img2.jpg','class'='some_class'))}

or:
Code:
{img src='images/img2.jpg' class='some_class'}

I know that i can use smarty's html_image, but img is just an example.
It's a general problem.

Do you have an opinion on that?


Messages In This Thread
Pass array parameter in helper function within smarty template - by El Forum - 02-12-2011, 02:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB