Re: [SMARTY] how do [iteration - 1] in template?
| From: | messju mohr | Date: | Fri, 09 Apr 2004 22:48:01 +0000 |
| Subject: | Re: [SMARTY] how do [iteration - 1] in template? | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11265@lists.php.net to get a copy of this message | ||
On Fri, Apr 09, 2004 at 04:42:34PM -0600, Rob Adams wrote:
>
> "Messju Mohr" <messju@lammfellpuschen.de> wrote in message
> news:20040321182828.GA3740@pharao.serveftp.org...
> > On Sun, Mar 21, 2004 at 05:25:24PM +0100, Kalle wrote:
> > >
> > > Hello Smarties,
> > >
> > > I would like to use "iteration - 1" as an index in an array:
> > >
> > > {foreach name=val key=key item=Val from=$Row}
> > > {if $ColNames[$smarty.foreach.val.iteration - 1]
> > > eq $PkNames[$smarty.foreach.val.iteration - 1]}
> > you have to assign this value to use it as an array index:
> >
> > {foreach name=val key=key item=Val from=$Row}
> > {assign var=index value=$smarty.foreach.val.iteration-1}
>
> I have a related question...
>
> I need to use the number of items in an array as a parameter to a smarty
> function. IE.
> {if count($items) > 9}
> {show_page_links cnt=count($items)}
use count as a modifier:
{show_page_links cnt=$items|@count}
(the @ is necessary to make the modifier work on the whole array
instead of each element)
> This obviously is the wrong syntax. I also tried using {assign} but ended
> up with the same value:
> cnt === count(Array)
>
> Can I do this without having to set another template variable? Thanks.
>
> -- Rob
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php