[TYPO3-mvc] FLUID: extended loop features

Franz Koch typo3.RemoveForMessage at elements-net.de
Wed Jan 6 17:45:54 CET 2010


Hi,

> I'm missing a few features of Smarty in the view helpers dedicated to rendering of loops. Smarty has
> a few convenient "variables" which will tell you a bit about the state of the loop. Therefore I
> propose a name attribute for all loop oriented view helpers.
...
> So which state properties do I want to query? Basically the loop counter. Everything else is purely
> for convenience.
>
> eg (with two attributes)
> <f:for each="{foobar}" as="item" loop="data" iteration="row">
>   <h3>{row.count}/{data.total}
>   <f:if condition="{row.isFirst}">  ...</f:if>
> </f:for>
> <p>{data.total} items listed</p>

I can only second that. Those features are quite handy and should be 
part of FLUID (if not already there, hidden under some stone)

> Here's my list of states I want to check:
>
> loop.total
> iteration.index (0 based)
> iteration.count (1 based)
> iteration.isFirst
> iteration.isLast
> iteration.isOdd
> iteration.isEven

looks good.

> As you can see "loop" has not much features, so it could be added to the iteration object as well.

Yes, I'd say to move it to the iteration object. But then "count" could 
be misleading as it could also deliver the total count. So I'd say:

iteration.index (0 based or SPLObjectKey)
iteration.cycle (1 based)
iteration.total (total count)


Btw. - I'm also in favor or your other suggestions - those are quite 
useful and simplify templating a lot (especially the optionSplit 
equivalent).

-- 
kind regards,
Franz Koch

---------------------------------------------------
PayPal-Account: 'paypal _at_ elements-net _dot_ de'
---------------------------------------------------


More information about the TYPO3-project-typo3v4mvc mailing list