Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

How to do a for-Iternation in Smarty?

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
iriePub
Smarty Regular


Joined: 16 Jun 2006
Posts: 53

PostPosted: Tue Aug 15, 2006 11:50 am    Post subject: How to do a for-Iternation in Smarty? Reply with quote

Hi,
if I have something like that in PHP:

Code:

$max = 10;
for($i = 20; $i > $max; $i--) {
  echo 'this is image ' . $i . '<br />';
}


Now I want the template to execute a for-Iteration, that depends on $max. I assign $max to Smarty like this:

Code:

$smarty->assign('max', $max);


But how to do the Iteration in Smarty?

Thanks!!
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Aug 15, 2006 12:16 pm    Post subject: Reply with quote

{section name=loop loop=$max} ... {/section}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
iriePub
Smarty Regular


Joined: 16 Jun 2006
Posts: 53

PostPosted: Tue Aug 15, 2006 12:44 pm    Post subject: Reply with quote

I'll try it, thanks!!
Back to top
View user's profile Send private message
iriePub
Smarty Regular


Joined: 16 Jun 2006
Posts: 53

PostPosted: Tue Aug 15, 2006 4:32 pm    Post subject: Reply with quote

hm, I don't understand it.
How can I do it like above posted, that I have a start value, and I give the direction of the development (increase / decrease) and the final value ?!
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Aug 15, 2006 5:18 pm    Post subject: Reply with quote

Are you asking because you don't understand the documentation? http://smarty.php.net/manual/en/language.function.section.php
Back to top
View user's profile Send private message
iriePub
Smarty Regular


Joined: 16 Jun 2006
Posts: 53

PostPosted: Tue Aug 15, 2006 8:40 pm    Post subject: Reply with quote

Sorry, I didn't close enough to see the thing "step" Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP