Re: [PHP Template] Request for comments - nested sections/looping/padding
[email protected] (Andrei Zmievski) Wed, 1 Mar 2000 14:13:44 -0600
| Newsgroups | php.template |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 01 Mar 2000, Monte Ohrt wrote:
> By default, $SCRIPT_NAME would print only in the first loop.
No, by default $SCRIPT_NAME would print on every iteration because it's
a scalar variable, but you're right that's sort of ambiguous.
> Here are some possible solutions:
>
> {{section sec1 default="" pad=last}}
>
> {{$SCRIPT_NAME}}<br>
> {{$title}}<br>
> {{$description}}
>
> {{/section}}
>
> This means that variables within the section are repeated with the last
> value once the array is out of variables.
So, you're saying that we can have default and pad attributes on section
level which provide the general settings for any variable that's seen
inside the section, and then each variable can override that? Does the
default/pad attribute set on an outer section affect the inner ones too?
Is it getting too complicated? :)
BTW, you don't need to set default="", it's already implied if not specified.
> So, by default the behavior will be:
>
> * single value variables should repeat its value for each iteration, but
> can be overridden with a variable attribute (loop=yes)
> * arrays should loop through the values, and have a blank value once the
> array is depleted, this can be overridden with a variable attribute
> (loop=no), or section attribute (default="" pad=none)
So, now we have three attributes that can be specified for a variable,
'loop', 'default', and 'pad'. My gut feeling is telling me it's getting
a little too complicated.
> Another crazy idea is to explicitly give the variables to be looped:
>
> {{section sec1 vars="title,description"}}
>
> {{$SCRIPT_NAME}}<br>
> {{$title}}<br>
> {{$description}}
>
> {{/section}}
>
> and by default, loop them all if attribute vars is not given. Or loop
> them all but single value vars. :-)
I'd call it loopvars=$title,$description or something like that, to be
more explicit. The only problem I see with this is what if you want to
loop through all but one variable, but I guess then you can use that
'loop' attribute on the variable itself. Hmm, I need more comments. :)
-Andrei
Politics is for the moment, an equation is for eternity.
-- Albert Einstein