Re: [SMARTY] 2.4.1: {assign} in tenmplates with arrays
| From: | Ferdinand Beyer | Date: | Fri, 07 Feb 2003 17:44:09 +0000 |
| Subject: | Re: [SMARTY] 2.4.1: {assign} in tenmplates with arrays | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7576@lists.php.net to get a copy of this message | ||
On 7 Feb 2003 at 17:14, Mark Rogers wrote:
> > This should also work (in this case):
> > {assign var=subject value="Hello, $test[name] from Joe"}
>
> .. gives a similar result:
> Hello, Array[name], from Joe
My fault. I didn't test it. I've just run a test and and taken a look at the
compiled result - obviously Monte has extended the parser to look
for vars in strings. That's why our example gets compiled to
(...) $this->_tpl_vars['test']."[name], from Joe" (...)
and PHP still converts the array to the string "Array".
> Maybe it was this form that used to work but now doesn't?
Yeah, you're absolutely right.
I didn't notice that because i have written a compiler function that has
the following syntax:
{set $var = $value + 'other values may be added using the +
operator'}
And compiles it to
<?php $this->_tpl_vars['var'] = $this->_tpl_vars + 'other (...)
operator'; ?>
Since it uses private Smarty_Compiler functions, it also supports
modifiers. Furthermore it is faster (and more powerful) than {assign}
since it gets compiled once (little slow) and there is not need to load
plugins afterwards.
But I confess it is more a hack than a real solution....
--
Ferdinand Beyer
<fbeyer@clickhand.de>