Re: [SMARTY] Re: passing an array to an included template
| From: | Jens Lehmann | Date: | Thu, 02 May 2002 20:04:31 +0000 |
| Subject: | Re: [SMARTY] Re: passing an array to an included template | ||
| References: | 1 2 3 4 5 6 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4002@lists.php.net to get a copy of this message | ||
Is it really good to have several "value"-keys? This imho causes
problems because the values are not be accessible via the
$params-array. How can I get around this or do you have
an other solution?
Jens
> You'll have to make a custom function.
>
> {assign_array var="foo" value="bar1" value="bar2"
> value="bar3"}
>
>
>
> Jens Lehmann wrote:
> > You almost got it. :-)
> >
> > The problem is to assign an array in the template (not in the
PHP-file!).
> > There is a function "assign" for this purpose.
> > You can look it up in the documentation under II 8. Custom Functions.
> >
> > The example in the documentation is:
> >
> > {assign var="name" value="Bob"}
> >
> > var and name are strings, that's why I see no possibility to assign an
array
> > in
> > a template. Imho this should be possible.
> >
> > If I want to do something like
> >
> > {assign var="name" value=array("test1","test2") }
> >
> > I won't get the expected result, because Smarty treats
> > array("test1","test2") as
> > an unquoted string (remember the assign-function expects a string) and
> > quotes
> > it. I removed Smarty's behaviour of quoting unquoted strings and
everything
> > works
> > fine.
> >
> > My question was if there's any possibility to assign an array in a
template?
> >
> > If no, I wanted to know if it could cause errors to remove Smarty's
> > behaviour
> > of quoting unquoted strings. (again you may look it up in
> > Smarty_Compiler.class.php
> > the lines around 1060 in Smarty 2.1.0)
> >
> > Anyways it could be a better solution to make assign accept arrays by
> > default, or not?
> >
> > An example:
> >
> > {assign var="name" values=("test1","test2") }
> >
> > Hopefully, you can understand my thoughts now.
> >
> > Jens
> >
> >