Skip to content

Instantly share code, notes, and snippets.

@Sebobo
Created June 16, 2021 09:37
Show Gist options
  • Save Sebobo/48fcc490e7655f66208aaf0259b43859 to your computer and use it in GitHub Desktop.
Save Sebobo/48fcc490e7655f66208aaf0259b43859 to your computer and use it in GitHub Desktop.
Optimized ContentReferences for NeosCMS
prototype(Neos.NodeTypes.ContentReferences:ContentReferences) >
prototype(Neos.NodeTypes.ContentReferences:ContentReferences) < prototype(Neos.Neos:ContentComponent) {
@context.referenceNodesArray = ${q(node).property('references')}
referenceNodes = Neos.Fusion:Collection {
collection = ${referenceNodesArray}
itemRenderer = Neos.Neos:ContentCase
itemName = 'node'
}
renderer = afx`
<div class="neos-nodetypes-contentreferences">
{props.referenceNodes}
{!props.referenceNodes ? I18n.translate('content.noReferencesSelected', '', [], 'NodeTypes/ContentReferences', 'Neos.NodeTypes.ContentReferences') : ''}
</div>
`
@cache {
mode = 'cached'
entryIdentifier {
node = ${node}
}
entryTags {
1 = ${Neos.Caching.nodeTag(node)}
2 = ${Neos.Caching.nodeTag(referenceNodesArray)}
3 = ${Neos.Caching.descendantOfTag(referenceNodesArray)}
}
}
// Prevent additional cache blocks from nested references
prototype(Neos.NodeTypes.ContentReferences:ContentReferences) {
@cache.mode = 'embed'
}
}
@Sebobo
Copy link
Author

Sebobo commented Jun 17, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment