|
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 |
RGordijn Smarty Rookie
Joined: 21 Jan 2008 Posts: 15
|
Posted: Fri Jan 25, 2008 10:48 am Post subject: a section in section |
|
|
Hi,
In my app I use a 'big' array to display some data.
Inside that array also exists some array wich I like to display.
this is the idea:
Code: |
{section name=b loop=$build}
foo: {$build[b].name}
{assign var=pr value=$build[b].product}
{section name=p loop=$pr}
{$pr[p].something}
{/section}
{/section} |
and this aint working, strange.... because when in the first section and i put: {$pr|print_r} in, the folowing appears:
Array ( [count] => 0.2 [something] => foobar )
so I'm confused. whats wrong with my code?
Thanks! |
|
Back to top |
|
RGordijn Smarty Rookie
Joined: 21 Jan 2008 Posts: 15
|
Posted: Fri Jan 25, 2008 11:27 am Post subject: |
|
|
well, working on the problem I found out what was wrong:
my array of products was not starting at zero, but the indexes where similar to the product id. like 4,5,9
and smarty is looping through an array, starting at zero, looping untill the number of required steps are done.
and not looking at the existing indexes of that array, why? i dunno, you tell me..
Rob |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Fri Jan 25, 2008 12:36 pm Post subject: |
|
|
Try using {foreach} instead of {section}. _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
RGordijn Smarty Rookie
Joined: 21 Jan 2008 Posts: 15
|
Posted: Fri Jan 25, 2008 1:29 pm Post subject: |
|
|
I tested with foreach, and it worked... thanks to uh.. uh.. 'messju' at the irc
now lets rebuild some big pieces of my app...
everytime i was rebuilding an array to start nicely with 0 index..
thanks |
|
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
|