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

Looping infinate number of foreach statements

 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
Jeremy-
Smarty Rookie


Joined: 11 Feb 2005
Posts: 16

PostPosted: Thu Dec 15, 2005 7:31 pm    Post subject: Looping infinate number of foreach statements Reply with quote

I'm aware of the possible drawbacks of doing this, but I want to be able to loop an infitnate amount of foreach statements to print out a document tree.

Each category has a sub category, that sub category has sub categories, and that sub has more subs... etc.. I have that built in an array. Now, how do I go about looping that in smarty?

The array is something along the lines of:

Array
(
[0] => Array
(
[id] => 1
[uri] => test_forum_1
[name] => Test Forum 1
[parent_id] => 0
[sub_forums] => Array
(
[0] => Array
(
[id] => 2
[uri] => test_forum_2
[name] => Test Forum 2
[parent_id] => 1
[sub_forums] => Array()
)

[1] => Array
(
[id] => 3
[uri] => test_forum_3
[name] => Test Forum 3
[parent_id] => 1
[sub_forums] => Array()
)

)
)

[1] => Array
(
[id] => 4
[uri] => test_forum_4
[name] => Test Forum 4
[parent_id] => 0
[sub_forums] => Array
(
[0] => Array
(
[id] => 5
[uri] => test_forum_5
[name] => Test Forum 5
[parent_id] => 1
[sub_forums] => Array
(
[0] => Array
(
[id] => 7
[uri] => test_forum_7
[name] => Test Forum 7
[parent_id] => 5
[sub_forums] = Array()
)
[1] => Array
(
[id] => 8
[uri] => test_forum_8
[name] => Test Forum 8
[parent_id] => 5
[sub_forums] = Array()
)

)
)

[1] => Array
(
[id] => 6
[uri] => test_forum_6
[name] => Test Forum 6
[parent_id] => 1
[sub_forums] => Array()



)
)

)


Any help is greatly appreciated. Smile
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Thu Dec 15, 2005 7:58 pm    Post subject: Reply with quote

Assuming you mean general recursion (ie: arbitrarilly nested structures) you should take a look here: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=291
Back to top
View user's profile Send private message
Jeremy-
Smarty Rookie


Joined: 11 Feb 2005
Posts: 16

PostPosted: Fri Dec 16, 2005 3:58 am    Post subject: Reply with quote

That looks like what I need. I'll post my questions in that thread. Thank you. Smile
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 -> Smarty Development 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