Search code examples
typo3extbasetypo3-10.x

What effect does it have to return in an Extbase action in TYPO3 v10?


e.g. an action does one of the following:

  1. return null;

  2. return $aString;

  3. no return

What is the effect?

The documentation is not clear to me, e.g.

As described in chapter 4 in section “controlling the flow”, it is not necessary to return the rendered content.

https://docs.typo3.org/m/typo3/book-extbasefluid/10.4/en-us/7-Controllers/1-Creating-Controllers-and-Actions.html#flow-pattern-display-a-list-of-domain-objects

So what if you do return a string? Is this displayed instead of using the Fluid template? Is returning null the same as returning nothing?


In v11 it is different but I am asking for v10.


Solution

  • For TYPO3 10 returning a string will display that string and not render the Fluid template. This is mostly useful if you want to display something other than HTML (like JSON for example, just use return json_encode($values);) or if you're getting your HTML from a different source (a webservice or a different templating system for example).

    Returning null is the same as returning nothing. So this will trigger the Fluid template rendering as normal.