Render existing node

Hi Folks,

I want to render an existing node (content element) of one page in another page - is that possible by fusion? It’s like setting a content reference by inspector/backend user interface, but doing that by code. Background is that I’m generating an amount of pages, and they shoud have one content element that is editable a one central place, because it’s for all the same. I can add a reference by hand to all 400 pages, but I would love to do this by code :slight_smile:

Thank you for ideas!

If you automate the creation of the pages you could at the same time also auto generate the references? Otherwise if you auto generate the one content element then you could basically hardcode the ID and find it in fusion by ID q(site).find('#the-node-id-here').get(0). So there is definitely options.
Also hello here! Didn’t know you (still) do Neos.

yes, hello here Christian, of course I (still) do Neos :slight_smile: And thanks for your immediate answer.
Finding the node to show is not the problem, for test I use a simple html-block with an image inside:

${q(site).find('[instanceof Vendor.Site:ImageLarge]').get(0)}

But I’m not able to render it :wink: Nothing will be shown, or, only the path like ‘Node /xx7/lajsdfl/sjdfla…’ as a string. First I tried to reproduce the usage of Neos’ ContentReferences, like this:

'Vendor.Produkte:Page':
   childNodes:
     referenceActionblock:
      type: 'references'

....
prototype(Vendor.Produkte:Page) < prototype(Vendor.Site:Page) {
    body {
        content {
		referenceActionblock = Neos.NodeTypes.ContentReferences:ContentReferences {
			@context.referenceNodesArray = ${q(site).find('[instanceof Vendor.Site:ImageLarge]').get()}
		}
	 }
}

....
{content.referenceActionblock -> f:format.raw()}

but nothing has been rendered. So I tried to reference the node directly:

'Vendor.Produkte:Page':
  childNodes:
    referenceActionblock:
      type: 'Vendor.Site:ImageLarge'

....
prototype(Vendor.Produkte:Page) < prototype(Vendor.Site:Page) {
    body {
    
    	@context.actionBlockNode = ${q(site).find('[instanceof Vendor.Site:ImageLarge]').get(0)}
    
        content {
		referenceActionblock = ${actionBlockNode}
	}
}

....
{content.referenceActionblock -> f:format.raw()}

with no success :-/ Last I changed this:

referenceActionblock = Vendor.Site:ImageLarge {
	@context.node = ${actionBlockNode}
}

but also nothing is shown. So, what is the recommended way to include/render an existing content element, or node, of one page in every other page of a specific type by default? Thank you :slight_smile:

logically, I want to set a reference as I would do by adding a node of type ‘Insert content references’ to the content collection of a page an then choosing a target node by inspector

The core of what you need to do is the same as the reference content does here

It takes a Neos.Fusion:Collection and passes the nodes to render as an array, and uses Neos.Neos:ContentCase as itemRenderer. Should be quite the same for you

This might also help https://neos.readthedocs.io/en/stable/HowTos/EditableSharedFooter.html

So, I finally solved it by using the nodePath of the existing content collection with the elements in that I want to share/include - as detailed described in this post: Rendering another Node inside a Node. Thank you for support guys :slight_smile: