Rendering another Node inside a Node

Long Question

How to render a node (in my particular case, how to render the PrimaryContent of another Node in my current node) in another node. Because giving that node to Fluid and trying to render it with “f:format.raw()” didn’t work and it was returning “Node /sites/.../node-560e263b1d0b0/main@live[TYPO3.Neos:ContentCollection]” on debugging i saw this was a node.

Basically this was what i was going to do:

contactFormThankYou = TYPO3.TypoScript:Collection {
    collection = ${q(node).find('#06f577f6-487c-d765-860f-b42f0577b902').children('main')}
    itemName = 'childNode'
    itemRenderer = TYPO3.TypoScript:Template {
        templatePath = 'resource://.../Private/Templates/ContactForm/ThankYou.html'
        node = ${childNode}
    }
}

But @christianm told me that i am just iterating on the nodes but not really render them

Short Question

How to render a node (into another one)

Solution

First of all thank you very much @christianm for your super fast and really good answer!

Using the ContentCollection we can give it’s “nodePath” the value of a FlowQuery like:

${q(node).find('SomeIdentifierGoingHere').get(0).path}

And now you can go to your Template and output it using f:format.raw, like this:

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

so for my case this simply means:

contactFormThankYou = TYPO3.Neos:ContentCollection {
	nodePath = ${q(node).find('#06f577f6-487c-d765-860f-b42f0577b902').children('main').get(0).path}
}

and the most important part is of course the “.path” at the end because this is what “nodePath” is requiring.

2 Likes

Alternatively the ContentCase TypoScript object can be used to render a node. You can find an example in the ContentReference node type in the node types package.