Re: [SMARTY] Array in modifier
| From: | messju mohr | Date: | Fri, 14 Nov 2003 14:21:36 +0000 |
| Subject: | Re: [SMARTY] Array in modifier | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10540@lists.php.net to get a copy of this message | ||
to quote the fine manual:
http://smarty.php.net/manual/en/language.modifiers.php
> If you apply a modifier to an array variable instead of a single value
> variable, the modifier will be applied to every value in that
> array. If you really want the modifier to work on an entire array as a
> value, you must prepend the modifier name with an @ symbol like so:
> {$articleTitle|@count} (this will print out the number of elements in
> the $articleTitle array.)
HTH
messju
On Fri, Nov 14, 2003 at 09:15:01AM -0500, Rémy Dufour wrote:
> Hi All,
> Is there a trick to pass an array to a modifier ? I've wrote this modifier
> function (and put it in my plugins directory) :
>
> function smarty_modifier_join($array, $glue = ', ')
> {
> return implode($glue, (array)$array);
> }
>
> Now, i have this array
>
> $myArray= array('One', 'Two', 'Blabla');
> $smarty->assign('myArray', $myArray);
>
> and this template
> {$myArray|join:" | "}
>
> I espect to got an ouput like this:
> One | Two | Blabla
> But i got this:
> Array
>
> What am i doing wrong ?
>
> Ps.: I use 2.6 RC2
BTW: you should upgrade :)
> Regards,
> Rémy Dufour