[TYPO3-mvc] How to use contains() in a condition in fluid

Franz Koch typo3.RemoveForMessage at elements-net.de
Sat Nov 20 12:54:25 CET 2010


Hey,

> Is it possible to test if an array contains an object in fluid? I want
> to do the following:
>
> ....
> <f:if condition="{team.members} CONTAINS {person}">
> <!-- Do something here -->
> </f:if>
> ...

definitely not with the if viewHelper, and I don't know any other 
default viewHelper that's capable to do this.

> Of course I can do the test in the controller and assign a boolean to
> use in fluid, but I think it would be more elegant to do the check in
> fluid.
>
> Alternatively I could write my own viewhelper doing the check.

I'd go the way with a custom viewHelper. You could have a look at the 
viewHelper incubator - maybe there's already a suitable one there 
(please search for it on forge or on this list, I don't have the URL at 
hand).

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list