我不太喜欢 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。不过我还没有准备好。