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

reset an array after a foreach

 
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
demental
Smarty Rookie


Joined: 11 Jan 2006
Posts: 20
Location: Lost in the French deeeeep countryside

PostPosted: Fri Feb 03, 2006 12:28 pm    Post subject: reset an array after a foreach Reply with quote

Hi everybody.

I have an array assigned to smarty, that I want to display twice on the same page, but in a different way (It's a FAQ page).

For now I have to assign the array plus a copy of it.
It would be far better if I could have only one array assigned, and reset it after the first loop.

The other idea was to make a capture, and append it inside the first foreach.

I checked in the manual but did not find anything about these two. Can someone advise me ?
Back to top
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Fri Feb 03, 2006 2:52 pm    Post subject: Reply with quote

You should be able to loop through the same array as many times as you want. I don't see a reason why you need to pass it in twice or do anything with eval as long as you didn't modify the array in the template.

Code:

{section name=nr loop=$faqarray}
   <div>{$faqarray[nr].questions}</div>
{/section}
<hr>
{section name=nr loop=$faqarray}
   <div>
      <p>{$faqarray[nr].questions}</p>
      <p>{$faqarray[nr].answers}</p>
   </div>
{/section}

_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
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