将内容从TypoScript传递到TYPO3 7.6中的流体模板

时间:2016-03-17 21:36:12

标签: typo3 fluid typo3-7.x typo3-7.6.x

我想通过TypoScript阅读内容并通过自定义流体模板进行渲染。没有css_styled_content或fluid_styled_content。

next()

这适用于字符串,比如说

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
  }
}

但不是

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

仅返回图像数量。

现在,在经典的TypoScript RenderObj(也许是COA)中,您可能会添加类似

的内容
<f:debug>{data.image}</f:debug>

虽然如今,我们希望在Fluid模板中实现这一目标。但是如何解析FAL图像以将其传递给流体模板?

2 个答案:

答案 0 :(得分:3)

您应该能够使用TYPO3\CMS\Frontend\DataProcessing\FilesProcessor数据处理器为您提取文件数据,以便您可以在模板中使用{files}访问它。

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

答案 1 :(得分:1)

主要问题是所有图像信息都存储在名为&#34; sys_file_reference&#34;的不同表中。选择&#34; tt_content.image&#34;在这里不会帮到你有两种方法可以解决这个问题,恕我直言。

1)创建自己的viewhelper。这个VH可以用来查询图像here

2)创建一个小的TypoScript lib并在流体模板中将其用作f:cObject。这被描述为here

我并不是说我的解决方案是最好的解决方案。但它是我所知道的唯一一个。期待看到更好的解决方案;)