typo3fluidtypo3-7.xtypo3-7.6.x

Pass content from TypoScript to fluid template in TYPO3 7.6


I would like to read content via TypoScript and render it through a custom Fluid template. Without css_styled_content or fluid_styled_content.

temp.test = CONTENT
temp.test {
  table = tt_content
  select.languageField = 1
  select.selectFields = bodytext,image,header,header_link
  select.where = colPos = 1
  renderObj = FLUIDTEMPLATE
  renderObj {
    file = path/to/Teaser.html
  }
}

This works with strings, say

<f:debug>{data.header}</f:debug>

But not with

<f:debug>{data.image}</f:debug>

returning only the number of images.

Now, in a classic TypoScript RenderObj (maybe a COA), you would have added something like

10 = FILES
10 {
  required = 1
  references {
    table = tt_content
    fieldName = image
  }
  renderObj = IMAGE
  renderObj {
    file.import.data = file:current:originalUid // file:current:uid
    file.width=654
    file.height = 327c
    //stdWrap.typolink.parameter.data = file:current:link
    altText.data = file:current:description // file:current:title // file:current:alternative
  }
}

While nowadays, we want to do that in the Fluid template. But how to resolve the FAL image to pass it to the fluid template?


Solution

  • You should be able to use the TYPO3\CMS\Frontend\DataProcessing\FilesProcessor data processor that will fetch the file data for you so you can access it with {files} in your template.

    renderObj = FLUIDTEMPLATE
    renderObj {
      file = path/to/Teaser.html
      dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        10.references.fieldName = image
      }
    }