Re: [SMARTY] 2.4.1: {assign} in tenmplates with arrays
| From: | Nichlas Löfdahl | Date: | Fri, 07 Feb 2003 17:18:16 +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-7575@lists.php.net to get a copy of this message | ||
Hello Mark!
One solution is to introduce a new modifier strcat, something like this:
modifier.strcat.php:
<?
function smarty_modifier_strcat($str1, $str2)
{
return $str1.$str2;
}
?>
In your template:
{assign var=subject value="Hello,"|strcat:$test.name|strcat:", from Joe"}
/Nichlas
----- Original Message -----
From: "Mark Rogers" <mark@quarella.co.uk>
To: <smarty-general@lists.php.net>
Sent: Friday, February 07, 2003 4:05 PM
Subject: [SMARTY] 2.4.1: {assign} in tenmplates with arrays
> I'm running current CVS (as of this morning). I'm fairly sure this used to
> work pre-2.4 but correct me if I'm wrong:
>
> $smarty->assign('test', array('name' => 'Mark'));
>
> ... and in template:
>
> {assign var=subject value="Hello, $test.name, from Joe"}
> {$subject}
>
> .. currently prints
> Hello, Array.name, from Joe
>
> .. where I obviously wanted
> Hello, Mark, from Joe
>
> I can work around this with
> {assign var=temp value=$test.name}
> {assign var=subject value="Hello, $temp, from Joe"}
> {$subject}
>
> .. but you try explaining that to a template designer :-)
>
> --
> Mark Rogers, Quarella Ltd
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.449 / Virus Database: 251 - Release Date: 28/01/2003
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php