Search code examples
typo3backendfluxfluid

TYPO3 fluid: f:format.html in backend removes links


I am using flux 9.5.0 in TYPO3 9.5.31 to create a simle "text" content element.

It has a preview section that is displayed in the TYPO3 backend with <f:format.html>:

  <f:section name="Preview">
    <f:format.html>{settings.text}</f:format.html>
  </f:section>

Unfortunately, links get removed and are not even their text displayed.

Example:

  • HTML in RTE: <p>before <a href="https://cweiske.de/" target="_blank">link</a> after</p>
  • Rendered output in preview: before after

How can I get the links in the preview section rendered?


Solution

  • This is a problem with TYPO3's fluid.

    TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper::simulateFrontendEnvironment() creates a dummy TSFE instance.

    TYPO3's ContentObjectRenderer expects $TSFE->cObjectDepthCounter to be > 0 when rendering nested tags in cObjGetSingle, and this fails because the dummy TSFE instance does not have this variable set.


    This problem is known since 2015: Bug #66855: Format/HtmlViewHelper don't render Links in TYPO3_MODE = BE

    According to https://forge.typo3.org/issues/67556 and https://forge.typo3.org/issues/96535 this is "fixed" in TYPO3 v11.5 if you switch to <f:transform.html>.