|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
h1nebefe Smarty Rookie
Joined: 20 Apr 2003 Posts: 7
|
Posted: Sun Apr 20, 2003 4:58 pm Post subject: First/Last values for {foreach} |
|
|
If it exists already please tell me
DocUK |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sun Apr 20, 2003 5:39 pm Post subject: |
|
|
you don't have the actual first and last values, but you have boolean-values to indicate wether the current iteration is the first or the last (or both ) . it this what you need ?
Code: |
{foreach name=foo from=$array}
{if $smarty.foreach.foo.first} do something {/if}
{$smarty.foreach.foo|@debug_print_var} // show what else is known for this foreach
{if $smarty.foreach.foo.last} do something {/if}
{/foreach}
|
HTH
messju |
|
Back to top |
|
h1nebefe Smarty Rookie
Joined: 20 Apr 2003 Posts: 7
|
Posted: Sun Apr 20, 2003 6:12 pm Post subject: |
|
|
That's what I meant! Thanks! |
|
Back to top |
|
guido Smarty Rookie
Joined: 02 May 2003 Posts: 9
|
Posted: Tue Jul 15, 2003 1:05 am Post subject: |
|
|
messju, since this isn't documented anywhere ..
what values work for foreach? compared to section..
I tried rownum and it didn't work in the foreach.. a list would be great. _________________ read docs .. read 'em .. uh oh i'm dumb |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jul 15, 2003 7:24 am Post subject: |
|
|
it is documented in the cvs-version of the docs. the docs on the smarty website will be updated with the next stable release of smarty (dunno when)
(from the docs)
iteration
iteration is used to display the current loop iteration.
Iteration always starts with 1 and is incremented by one one each iteration.
first
first is set to true if the current foreach iteration is the first one.
last
last is set to true if the current foreach iteration is the last one.
show
show is used as a parameter to foreach. show is a boolean value, true or false. If false, the foreach will not be displayed. If there is a foreachelse present, that will be alternately displayed.
total
total is used to display the number of iterations that this foreach will loop. This can be used inside or after the foreach.
HTH
messju |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|