RE: [SMARTY] {assign} possibility?
| From: | Scott Matthewman | Date: | Tue, 29 Oct 2002 17:06:56 +0000 |
| Subject: | RE: [SMARTY] {assign} possibility? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6265@lists.php.net to get a copy of this message | ||
In general you should be thinking of using modifiers in this context - after
all, if template designers need to learn PHP it removes one of the
advantages of having a separate template system in the first place :-) If
you're committed to using only the modifiers that come with the Smarty
release:
{assign var="letter" value=$aItem.lastname|lower|truncate:1:"":true}
Some existing PHP functions can be used as modifiers as well:
{assign var="letter" value=$aItem.lastname|lower|substr:0:1}
However, if you're going to be using this type of modification regularly,
I'd suggest making a custom modifier function for the purpose.
Scott
> -----Original Message-----
> From: Mitch Vincent [mailto:mitch@unixprogramming.net]
> Sent: 29 October 2002 16:47
> To: smarty-general@lists.php.net
> Subject: [SMARTY] {assign} possibility?
>
>
> {assign var="letter" value=substr(strtolower($aItem.lastname), 0, 1)}
>
> gives
>
> FATAL: [256] Smarty: [in admin/admin.tpl line 16]: syntax error:
> invalid attribute name - '0,'
>
> So is there a way to embed php functions in {assign} like that?
>
> -Mitch
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>