打字3 7.4.通过打字脚本获取tt_content文本媒体图像


typo3 7.4. get tt_content textmedia images via typoscript

我正在创建一个新页面,并尝试使页脚在后端可编辑。因此,我创建了一个新的tt_content textmedia元素,并通过打字脚本将其保存到一个变量:

footerdata = RECORDS
footerdata {
  tables = tt_content
  source = 165
  dontCheckPid = 1
  conf.tt_content = COA
  conf.tt_content {
    10 = TEXT
    10.field = header
    10.wrap = <h1>|</h1>
    20 = TEXT
    20.field = bodytext
    20.parseFunc =< lib.parseFunc_RTE
    20.wrap = <div>|</div>
  }
}

在我的模板中,我只需将其添加到页脚:

<f:format.raw>{footerdata}</f:format.raw>

这对标题和文本很好,但我根本不知道如何对图像进行处理。有人有任何教程,链接等,我可以在哪里查找?我试着用谷歌搜索这个问题,但Typo3 7似乎太新了,没有任何可行的提示。

提前感谢!

我不太喜欢RECORDS对象;我一直觉得它很神秘。

我通常将这样的条目放在一个系统文件夹中,然后获取该pid的所有内容。

老派方法:

lib.address = CONTENT
lib.address {
    wrap = |
    table = tt_content
    select.languageField = sys_language_uid
    # uncomment if you want to be more specific
    # select.selectFields = bodytext,image,header,header_link
    # or if you want to limit by colPos
    # select.where = colPos = 6
    # This is your "Address" Sysfolder's pid
    # It's nice to keep such hardwired values in constants
    # ... but of course you can also just do = 123
    # select.pidInList = {$pidAddress}
    # here, the rendering is done
    renderObj=COA
    renderObj{
      wrap = |
      # That's how you process the FAL files
      # This is since TYPO3 6.2 btw
      5 = FILES
      5 {
        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
          }
      }
      # Let's say you want the other content here
      10 = COA
      10 {
            1=TEXT
            1{
                required=1
                wrap=<h1>|</h1>
                field=header
            }
            2=TEXT
            2{
                required=1
                wrap=<div>|</div>
                field=bodytext
            }
        }
     }
}

在您的页面模板中,以的形式访问cObject

<f:cObject typoscriptObjectPath="lib.breadcrumb" />

此外,还有一种更现代的方法,它使用流体模板作为renderObj:

lib.address = CONTENT
lib.address {
  # same as above
  wrap = |
  table = tt_content
  select.languageField = sys_language_uid
  # here it's getting different
  renderObj = FLUIDTEMPLATE
  renderObj {
    file = {$customContentTemplatePath}/MyFile.html
    layoutRootPath = {$customContentLayoutPath}
    partialRootPath = {$customContentPartialPath}
    dataProcessing {
      // https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html
      // available data processors: SplitProcessor, CommaSeparatedValueProcessor, FilesProcessor, DatabaseQueryProcessor, GalleryProcessor
      10 = TYPO3'CMS'Frontend'DataProcessing'FilesProcessor
      10.references.fieldName = image
    }
    //settings {
    // type = some_setting
    //}
  }
}

下面是一个示例,我将如何使用流体模板来渲染该对象,完全可选使用VHS viewhelper扩展(EXT:VHS)

{namespace v=FluidTYPO3'Vhs'ViewHelpers}
<div class="small-12 medium-6 large-4 columns">
    <f:for each="{files}" as="file">
        <v:media.image src="{file}" srcset="1200,900,600" srcsetDefault="600" alt="{file.alternative}" treatIdAsReference="1"/>
    </f:for>
    <h1>{data.header}</h1>
    <div>{data.bodytext}</div>
</div>
<f:comment>
// memory help for debugging:
<f:debug>{data}</f:debug>
<f:debug>{settings}</f:debug>
<f:debug>{file}</f:debug>
</f:comment>

更正确地说,renderObj应该被DataProcessor替换。不过我还没有准备好。

另一种方法可以是使用VHS扩展并使用render.record viewhelper:

https://fluidtypo3.org/viewhelpers/vhs/master/Render/RecordViewHelper.html