[TYPO3-mvc] If-ViewHelper problems

Bastian Waidelich bastian at typo3.org
Mon Jul 27 12:17:14 CEST 2009


Andriy Kushnarov wrote:

Hi Andriy,

> <ul>
> 	<f:for each="{users}" as="user" key="index">
> 		<li <f:if condition="{index} %
> 2">class="even"</f:if>">{user.firstName} {user.lastName}</li>
> 	</f:for>
> </ul>
> 
> does it work? As for me it doesn't :)

This should work, but there will be a cleaner solution very soon 
(hopefully tomorrow):

<ul>
	<f:for each="{users}" as="user" key="index">
		<li class="{f:cycle (values="{0: 'odd', 1: 'even'})}>
			{user.firstName} {user.lastName}
		</li>
	</f:for>
</ul>

Or, alternatively:

<ul>
	<f:for each="{users}" as="user" key="index">
		<f:cycle values="{0: 'odd', 1: 'even'}" as="zebra">
			<li class="{zebra}">
				{user.firstName} {user.lastName}
			</li>
		</f:cycle>
	</f:for>
</ul>


Bastian


More information about the TYPO3-project-typo3v4mvc mailing list