Populate ContentCollection with content from parent page


i´m trying to populate a ContentCollection on a child page with the content from a ContentCollection of its parent page, so that i don´t have to define the same content multiple times, parent and child are using different page layouts. Somebody know if this is possible and can help?

Best Regards

Hey @damonx,

check the documentation:

This should do the work for you!

You don’t really need a ContentCollection in the child page, you can get the content from the parent page, with a FlowQuery, and render those node in the child page. We use this kind of thing on the opposite direction to render big one pager. From the main page we get all contents from subpage, and render everything in a single page.

# Get the parent document, if you use Your.Package:SectionHomePage as node type for the parent document
parentSectionDocument = ${q(documentNode).closest('[instanceof Your.Package:SectionHomePage]').get(0)}
# If the content collection is at path 'sidebar'
parentSectionCollection = ${q(this.parentSectionDocument).find('sidebar').get(0)}

In your Fluid template:

{parentSectionCollection -> f:format.raw()}

thank you, i tried following in my typoscript:

subpagelayout < page
subpagelayout.body.templatePath = 'resource://My.Package/Private/Templates/Page/Subpage.html'
subpagelayout.body.parentSectionDocument = ${q(documentNode).parent('[instanceof TYPO3.Neos.NodeTypes:Page]').get(0)}
subpagelayout.body.parentSectionCollection = ${q(this.parentSectionDocument).find('top').get(0)}

When the subpage now is rendered, it shows a path, not the content:

Node /sites/mypage/node-56f02c7eec791/top@live[TYPO3.Neos:ContentCollection]

How do you render the collection in your template?

<f:section name="body">
{parentSectionCollection -> f:format.raw()}

Is there another way to render the collection? I can´t find out what i´m doing wrong here.

Try to use
subpagelayout.body.parentSectionCollection = ${q(this.parentSectionDocument).find('top').children().get()}

1 Like