Re: New looping method proposal

From: Date: Wed, 21 Nov 2001 22:01:46 +0000
Subject: Re: New looping method proposal
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2024@lists.php.net to get a copy of this message
On Wed, 21 Nov 2001, David M. Patterson wrote: > Hi everybody. > > I've been watching the discussion about a new looping construct for the > past few days. > > IMHO, the {section} tag is the most logical place to support > associative arrays. butt there seems to be some technical problem > with that. > > I haven't taken the time to dig into the Smarty sources, and was > wondering if I could get someone (Monte or Andrei?) to take a step > back for me and explain the underlying reason that the {section} > tag can't be made to nicely support associative arrays. {section..} is meant for looping through sequential arrays (one or multiple). It supports attributes and properties that simply would not make much sense when you loop through associative and non-sequential arrays; at the very least, if you wanted to support those attributes and properties the code for {section..} would need to be extensively modified. This leads to another reason for not using {section..} -- you would have to introduce new attributes to specify the key and value variables that should be assigned values during looping, and that is just not very clean. In a nutshell, overloading {section..} for this purpose is a wrong approach, IMHO. That is why we are thinking of introducing {foreach..}. The only thing I want figured out is what properties and attributes it should support; even if some of them are similar to {section..} ones, the implementation will be different. -Andrei * "I'll need daily status reports on why you're so behind." -- Dilbert's boss *

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