[TYPO3-mvc] Fluid - is there a way to check if an object is the first or last object?
Bastian Waidelich
bastian at typo3.org
Mon Jul 26 13:49:28 CEST 2010
Bastian Waidelich wrote:
Hi all,
FYI:
> Tomorrow I'll try to add this extended for ViewHelper to the Incubator
> distribution, then you'll be able to use it already.
We've just extended the for ViewHelper with the iteration data (Thanks
to a lot of patches from the community).
So with the latest version of tx_fluid you can write:
<f:for each="{items}" as="item" iteration="itemIteration">
<li class="item{f:if(condition: itemIteration.isFirst, then: '
first-child')}">{item}</li>
</f:for>
other iteration infos are:
itemIteration.index (0 based index of the iteration)
itemIteration.cycle (the same as index, but starting from 1)
itemIteration.total (total number of items)
itemIteration.isFirst (TRUE for the first item in the iteration)
itemIteration.isLast (TRUE for the last item in the iteration)
itemIteration.isOdd (TRUE for odd cycles 1,3,5,...)
itemIteration.isEven (TRUE for even cycles 2,4,6,...)
Have fun ;)
Bastian
More information about the TYPO3-project-typo3v4mvc
mailing list