Re: [SMARTY] how do [iteration - 1] in template?

From: Date: Fri, 09 Apr 2004 22:42:34 +0000
Subject: Re: [SMARTY] how do [iteration - 1] in template?
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11264@lists.php.net to get a copy of this message
"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)} 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

« previous php.smarty.general (#11264) next »