1

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

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 似乎是新的,没有任何可行的提示。

提前致谢!

4

2 回答 2

3

我不太喜欢 RECORDS 对象。我总觉得它很神秘。

我通常将这些条目放在一个 sysfolder 中,然后获取该 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 视图助手扩展 (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。不过我还没有准备好。

于 2016-04-11T13:18:22.193 回答
1

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

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

于 2016-04-11T13:53:11.673 回答