WEBcoast Logo

Fluid in TYPO3 CMS 8: <f:switch>with default case

In TYPO3 CMS 8 the integrated Fluid was replaced by the separate typo3fluid/fluid package. This brings some interesting changes. Among others, the handling of <f:switch> has changed. Up to and including TYPO3 CMS 7 an <f:switch> looked like this:

<f:switch expression="{someVariable}">
    <f:case value="...">...</f:case>
    <f:case value="...">...</f:case>
    <f:case value="...">...</f:case>
    <f:case default="1">...</f:case>
</f:switch>

It was important to place the default case at the end, because it caused the rendering to stop and all further cases were not checked. In the new external Fluid package the attribute default has been removed. The old template would therefore cause an exception. In TYPO3 CMS 8 an <f:switch> looks like this:

<f:switch expression="{someVariable}">
    <f:case value="...">...</f:case>
    <f:case value="...">...</f:case>
    <f:case value="...">...</f:case>
    <f:defaultCase>...</f:defaultCase>
</f:switch>

The default case can be place where ever you want, because it is handled separately. It took me some time to figure this out. I hope I can help one or another avoid this hassle.