简体   繁体   English

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

[英]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. 我想通过TypoScript阅读内容,并通过自定义的Fluid模板进行渲染。 Without css_styled_content or fluid_styled_content. 没有css_styled_content或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 现在,在经典的TypoScript RenderObj(也许是COA)中,您应该添加类似

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. 如今,我们希望在Fluid模板中执行此操作。 But how to resolve the FAL image to pass it to the fluid template? 但是如何解析FAL图像以将其传递到流体模板?

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. 您应该能够使用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
  }
}

The main problem is all image information are stored in a different table called "sys_file_reference". 主要问题是所有图像信息都存储在另一个名为“ sys_file_reference”的表中。 Selecting "tt_content.image" will not help you here. 选择“ tt_content.image”对您没有帮助。 There are 2 ways to solve this problem, IMHO. 有两种方法可以解决此问题,恕我直言。

1) Create your own viewhelper. 1)创建自己的viewhelper。 This VH can be utilized to query the images as it is done here . 这个VH可以用来查询图像,就像在这里完成的那样。

2) Create a small TypoScript lib and use it as f:cObject in your fluid template. 2)创建一个小的TypoScript库,并将其用作流体模板中的f:cObject。 This is described here . 在这里描述。

I'm not saying that my solution is the best one. 我并不是说我的解决方案是最好的。 But it's the only one I'm aware of. 但这是我所知道的唯一一个。 Looking forward seeing better solutions ;) 期待看到更好的解决方案;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM