Smarty loop overhead question

Discussion corner for Developers of Serendipity.
Post Reply
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Smarty loop overhead question

Post by Don Chambers »

I have a need for a simple loop in a template. Smarty 3 (s9y >=1.7) has the function {for}, ie {for $var=$start to $end} ... but smarty 2 (s9y < 1.7) doesn't have that. Closest I could find was {section}, as in {section name=whatever loop=$end}, which also works in smarty 3.

Is it worth doing a conditional test on $head_version, then using the corresponding function (for > 3, section < 3), or just live with {section} since it works in both? Is there an overhead impact?
=Don=
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Smarty loop overhead question

Post by onli »

Do you really want to target version before s9y 1.7? They are not safe to use anymore. In my eyes, for every project with not very specific requirements you should just use smarty 3 syntax.

Otherwie we would could try to look at the generated php code, but then the code would be already there and a short benchmark probably the best way to go.
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Smarty loop overhead question

Post by Don Chambers »

I looked at the generated php code in templates_c. The {section} function generates considerably more code... approximately 20 lines of code compared to {for} which generated only 4 lines of code. Guess I will go with {for} and have a template requirement of >= 1.7
=Don=
Post Reply