Re: [SMARTY] Foreach - get the line number

From: Date: Wed, 02 Jul 2003 15:14:00 +0000
Subject: Re: [SMARTY] Foreach - get the line number
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9812@lists.php.net to get a copy of this message
Thx a lot, this help me a lot. I was looking for this for both section and foreach loops. Maybe it would be great to add this to the online doc. (and not only FAQ). Cordialement, Olivier Doucet Webmaster de www.ajeux.com ----- Original Message ----- From: "messju mohr" <messju@lammfellpuschen.de> To: "Olivier Doucet [reagi.com]" <webmaster@ajeux.com> Cc: <smarty-general@lists.php.net> Sent: Wednesday, July 02, 2003 4:59 PM Subject: Re: [SMARTY] Foreach - get the line number > On Wed, Jul 02, 2003 at 04:39:12PM +0200, Olivier Doucet [reagi.com] wrote: > > I'm using foreach to go throuh a big array. > > But i want to show the number of the line. > > > > {foreach from=$lesfiches item=fiche} > > $i - <a > > href="ct_faq.php?id={$fiche.id}">{$fiche.titre}</a><br> > > > > {/foreach} > > > {foreach from=$lesfiches key=i item=fiche} > {$i} - ... > {/foreach} > > or > > {foreach name=f from=$lesfiches item=fiche} > {$smarty.foreach.f.iteration} - ... > {/foreach} > > the former is documented at: > http://smarty.php.net/manual/en/language.function.foreach.php > > the latter is only in the cvs-version of the docs, but available in > smarty since 2.3.x AFAIK. > > > > > Replace $i by the number of the line, ie : > > 1- <a href="ct_faq.php?id=51">Title</a><br> > > 2- <a href="ct_faq.php?id=31">Title</a><br> > > 3- <a href="ct_faq.php?id=47">Title</a><br> > > > > I haven't seen how to do this in the doc. Can u help me ? > > > > Thx a lot :) > > > > > > Olivier Doucet > > www.ajeux.com > > > > -- > > Smarty General Mailing List (http://smarty.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php

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