Re: [SMARTY] assign template var with number of elements of an array

[email protected] (Owen Cole) Fri, 20 Oct 2006 17:08:28 -0400
Newsgroups php.smarty.general
Organization Total Sales & Marketing
Message-ID <[email protected]>
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
>