[TYPO3-mvc] multiple conditions in if viewhelper
Franz Koch
typo3.RemoveForMessage at elements-net.de
Tue Mar 8 11:03:35 CET 2011
Hey,
> i want to make a condition with multiple things i want to check for like
> this:
>
> <f:if condition="{first} == 0 || {second} == 0 || {third} == 0">
>
> but now i get an exception:
> #1244201848: The expression "0 == 0 || 0 == 0 || 0 == 0" has more than
> tree parts.
>
> why do i get an exception like that? is there any workaround?
The Fluid parser can currently only evaluate one boolean expression.
Someone (sorry, don't remember the name) mentioned that you could use
arrays to evaluate multiple expressions as a workaround, but that
probably won't work in the same way as your condition:
<f:if condition="{0:first, 1:second, 2:third} == {0:0, 1:0, 2:0}">
<f:then>all of them 0</f:then>
<f:else>at least one of them not 0</f:else>
</f:if>
Another workaround is to add a boolean getter to your models internally
evaluating the condition - but that only works if all parts of the
condition are from the same model.
<f:if condition="{myObject.isValid}">...</f:if>
public function getIsValid() {
return !($this->getFirst() == 0 || $this->getSecond() == 0 ||
$this->getThird() == 0);
}
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list