Re: New looping method proposal

From: Date: Mon, 19 Nov 2001 16:22:35 +0000
Subject: Re: New looping method proposal
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1966@lists.php.net to get a copy of this message
{foreach $people as $person} {$person.firstname} {$person.lastname} {/foreach} same code: {section name=person loop=$people} {$people[person].firstname} {$people[person].lastname} {/section} OK, now we want to loop through two variables: {foreach $index => $people as $person} {$person[$index].firstname} {$person[$index].lastname} {$foo[$index]} {/foreach} same code: {section name=person loop=$people} {$people[person].firstname} {$people[person].lastname} {$foo[person]} {/section} I don't think we'd be gaining too much by adding {foreach} since this can already be done with the current syntax. We would only be adding unnecessary complexity to Smarty's language, IMHO. Maybe the syntax of these section loops doesn't matter a whole lot, depending on the way programmers and designers work together. For example, in our case more times than not, the programmer sets up the section loops in the skeleton templates, then the designers adjust the HTML code around them. Sometimes they need to make adjustments, but they seem perfectly content figuring out what they need from the existing section loop and the debug console. If they had to build the sections from _scratch_ on the other hand, I don't think they'd like that at all. Whether the syntax was {section ...} or {foreach ...}, they don't want the task of setting these up, it is a waste of their time since it only distracts their creativity :-) What are others thoughts on this? How do you function in your environment? (and I don't mean where programmer/designer are the same person) Andreas Kossmeier wrote: > > hi, > > Anders Janson wrote: > > If the {foreach} could be hacked as a plugin or custom function, I'd > > say "Yes!! Go for it!!". > > it wouldn't be a plugin nor a custom function, it's just an addition to > the (smarty) language, the functionality is basically the same, it's > just an easier way of using it. > > you shouldn't compare this with e.g. a specialized table function, it's > basically not the same (language contructs vs. custom functions). > > > Which means the only way is to hack the Smarty core, and I really > > don't like the thought. > > - If it works, don't fix it. > > - If it is too specialized: don't add it. > > - If it is optional - Sure, why not!? > > if we can enhance the (smarty) template language, why shouldn't we > think about it? and since it is only an addition, i think, it's worth > considering. > > andreas > > -- > andreas kossmeier > Hyperwave AG Graz - http://www.hyperwave.com > > --- > You are currently subscribed to smarty as: monte@ispi.net > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

« previous php.smarty.general (#1966) next »