Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

a section in section

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
RGordijn
Smarty Rookie


Joined: 21 Jan 2008
Posts: 15

PostPosted: Fri Jan 25, 2008 10:48 am    Post subject: a section in section Reply with quote

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
View user's profile Send private message
RGordijn
Smarty Rookie


Joined: 21 Jan 2008
Posts: 15

PostPosted: Fri Jan 25, 2008 11:27 am    Post subject: Reply with quote

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
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Fri Jan 25, 2008 12:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
RGordijn
Smarty Rookie


Joined: 21 Jan 2008
Posts: 15

PostPosted: Fri Jan 25, 2008 1:29 pm    Post subject: Reply with quote

I tested with foreach, and it worked... thanks to uh.. uh.. 'messju' at the irc Wink

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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