|
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 |
ferre Smarty Rookie
Joined: 07 Jul 2003 Posts: 28
|
Posted: Mon Oct 06, 2003 4:07 am Post subject: for($i=1;$i<=$count;$i++) |
|
|
in php
for($i=1;$i<=$count;$i++)
{
xxxxxxx
}
but in smarty, i assign("COUNT",$count);
what should i do , plz help |
|
Back to top |
|
mikeken Smarty Regular
Joined: 13 Aug 2003 Posts: 57 Location: MN
|
Posted: Mon Oct 06, 2003 8:13 pm Post subject: |
|
|
What is your question?
I see you want to do something...but what? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Oct 06, 2003 9:31 pm Post subject: |
|
|
my crystal-sphere may lie, but i think you want:
{section name=i loop=$count}
i is: {$smarty.section.i.iteration}
{/section} |
|
Back to top |
|
idxman01 Smarty Rookie
Joined: 10 Jun 2003 Posts: 14 Location: FL
|
Posted: Wed Dec 03, 2003 8:33 pm Post subject: |
|
|
Thanks for the info messju, that's what I was just looking for.
Although I'm running into a problem during the loop. Basically I have a variable number of loops per row, where the variable name contains the loop number.
eg:
$results is an array of objects that I'm already looping through.
$results[row]->r_nbr_tpl is an integer from 0-5
So then I need to iterate that many times and print out vars like:
r_tpl_cc_1 , r_tpl_cc_2
Code: |
{section name=row loop=$results}
//print stuff
{section name=i loop=$results[row]->r_nbr_tpl}
// ok, so this is where I'd need to print $results[row]->r_tpl_cc_1, 2, 3, etc. depending on what loop section i was on.
I've tried: {$results[row]->r_tpl_cc_$smarty.section.i.iteration} , but I get parse errors in the compiled template.
{/section}
{/section}
|
any ideas?
Thanks,
-r |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Dec 03, 2003 10:32 pm Post subject: |
|
|
use arrays instead of variable variables. i think that's the best one in the long run.
greetings
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
|