Re: Limiting the section loop
| From: | Monte Ohrt | Date: | Tue, 26 Jun 2001 16:47:22 +0000 |
| Subject: | Re: Limiting the section loop | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-989@lists.php.net to get a copy of this message | ||
Andrei Zmievski wrote:
>
> On Tue, 26 Jun 2001, Anders Janson wrote:
> > Good to know, but this is not really a limit. It forces the loop to run N
> > times.
> > What I was looking for was a way to limit it to *max* N times. This does not
> > work properly if my data array(s) are shorter than N elements.
>
> Ok, then in order for us to implement it properly we should define
> precise behavior of this 'max' attribute. What should it do in the
> following cases:
>
> $input = array(1, 2, 3, 4);
>
> {section loop=$input max=0}
> {/section}
Same behavior as show=false. I could see if you are setting max with a
variable, you would want 0 to not loop.
>
> {section loop=$input max=-4}
> {/section}
syntax error, max must be >= 0.
>
> {section loop=5 max=3}
> {/section}
loop three times, just as if loop was a five element array
>
> {section loop=5 max=0}
> ...
> {sectionelse}
> ... does this get shown when max <= 0?
> {/section}
Yes, same behavior as show=false
Also, how about the "skip" and "step" attributes? ;-) step could allow
you to traverse the elements backwards!
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/