[TYPO3-mvc] Different Layouts in Fluid

Claus Due claus at wildside.dk
Wed Jun 20 21:24:25 CEST 2012


On Jun 20, 2012, at 8:38 PM, Ralf-Rene Schröder wrote:

> <f:layout name="<f:if
> condition="{homepage}"><f:then>homepageLayout</f:then><f:else>defaultLayout</f:else></f:if>"
> />

Hi Ralf-Rene and others,

Just to clarify: this is not the correct way to nest ViewHelpers (as it messes with validators
and highlighters - but it does work). The correct way is:

<f:layout name="{f:if(condition: '{someVar} > 0', then: '{f:something()}', else: '{f:somethingElse()}')}" />

Note the single quotes enclosing the "condition" argument; if you only want to check if a
variable does not evaluate to FALSE you do not need these, but if you want to compare
the value you _must_ use quoting. The same thing goes for all arguments that you want
to specify as inline ViewHelper calls.

If you have more levels of inline nesting you must be very careful about escaping your
quoted ViewHelper arguments. I forgot the link, but there is a detailed explanation in a
wiki somewhere - possibly FLOW3 related.

General tip though: if your conditions require this type of very complex nesting you are
probably much better off performance- and logic-wise assigning the variable elsewhere
like Controller, a custom ViewHelper or TypoScript. TypoScript or VH may be preferable
here since you are targeting page templates (what I gather from skimming the messages).


Cheers,

Claus
http://fedext.net


More information about the TYPO3-project-typo3v4mvc mailing list