|
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 |
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Apr 25, 2003 6:38 pm Post subject: Suggestions for un-rolling recursive template calls |
|
|
Anyone have a suggestion on how I can avoid a recursion?
I currently have a template that accepts an hierarchical data structure. The template tracks the level and for each level, outputs results . If it detects a sub-level, it opens a loop for the sub-level and within the loop, {include}s the same template again (itself), passing in an incremented level and the sub-level's data structure. With caching (smarty and PHP) the performance is usable, but still not great.
I want to avoid this recursion, but I can't think how to unroll the loop in smarty (since there is no while block). Should I just encase the loop in {php} blocks while code? It looks like an ugly hack and I haven't even tried that yet.
I don't want to change how the data is delivered to the template--if possible, I want to keep the hierarchical, self-repeating structure.
edited |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Apr 25, 2003 6:51 pm Post subject: |
|
|
i think this cannot be unrolled with smarty's built in loops.
if you don't have problems with a non-stable version,
use cvs's repeatable block-functions for this. it was made
for just that |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Apr 25, 2003 6:58 pm Post subject: |
|
|
Yeah, I was thinking along those lines.
This is meant for a production site, so I didn't want to rely on the CVS code. I guess someone has to test it out though, huh?
I'll try it out, but I'm still interested to hear what others would do. The way I have my loop setup, "all" I really need to do is reassign the data portion of the loop while signalling the control of the loop to reevaluate its context based on the new data (ie. reset the loop with new data from within the loop).
Conceptually similar to reassigning the loop index from within the loop. (YES, against CS principles, but shhh don't tell!) Which gives me an idea... |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Apr 25, 2003 7:13 pm Post subject: |
|
|
okay. i don't know when there will be a stable release that contains the repeat-stuff.
(but if you want to try, i'll help, if you have questions ) |
|
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
|