Re: [SMARTY] assign template var with number of elements of an array
| From: | Owen Cole | Date: | Fri, 20 Oct 2006 21:08:28 +0000 |
| Subject: | Re: [SMARTY] assign template var with number of elements of an array | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-13523@lists.php.net to get a copy of this message | ||
Hello Nuno,
You can use php functions as modifiers in Smarty. Also since this is an array you need to use the @ syntax to work on the whole array.
If you are just trying to display the count:
{$banners|@count}
If you really need to assign it to a variable for some other purpose:
{assign var="banners_count" value=$banners|@count}
Hope this helps!
Nuno Mendes wrote:
Hi, I'm trying to create a variable inside a template (banners_count) and it's value needs to be the number of elements of an array. I am using this but it's not working. {assign var=banners_count value=count($banners)} How can it be done? Thanks! Nuno