我已经定义了一个自定义文档节点Project
,它有一个子节点gallery
(只是图像的内容集合):
'Vendor.Website:Project':
superTypes: ['TYPO3.Neos:Document']
childNodes:
gallery:
type: 'TYPO3.Neos:ContentCollection'
constraints:
nodeTypes:
'TYPO3.Neos.NodeTypes:Image': TRUE
'*': FALSE
相应的TypoScript是:
prototype(TYPO3.Neos:PrimaryContent).project {
condition = ${q(documentNode).is('[instanceof Vendor.Website:Project]')}
type = 'Vendor.Website:Project'
}
prototype(Vendor.Website:Project) < prototype(TYPO3.Neos:Content) {
node = ${node}
gallery = TYPO3.Neos:ContentCollection {
nodePath = 'gallery'
}
}
相应的模板是:
{namespace neos=TYPO3\Neos\ViewHelpers}
{namespace flow=TYPO3\Flow\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}
<article>
<ts:render path="gallery" />
</article>
但只要内容集gallery
未命名为main
,我就只能使用内容画布而不是结构树将图像添加到gallery
中禁用的按钮create new
。有人知道为什么吗?
更新
我还尝试使用其他页面渲染器,如评论中建议的那样:
project < page
project {
body {
templatePath = 'resource://Vendor.Website/Private/Templates/Page/Project.html'
content {
main >
gallery = PrimaryContent
gallery {
nodePath = 'gallery'
}
}
}
}
为此,我还更新了节点类型定义:
'Vendor.Website:Project':
superTypes: ['TYPO3.Neos:Document']
childNodes:
gallery:
type: 'TYPO3.Neos:ContentCollection'
constraints:
nodeTypes:
'TYPO3.Neos.NodeTypes:Image': TRUE
'*': FALSE
properties:
'layout':
type: string
defaultValue: 'project'
至少是project
模板:
<!DOCTYPE html>
{namespace neos=TYPO3\Neos\ViewHelpers}
{namespace flow=TYPO3\Flow\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}
<html>
<head>
</head>
<body>
<f:section name="body">
<main>
{content.gallery -> f:format.raw()}
</main>
</f:section>
</body>
</html>
但结果相同。