element<Neos.NodeTypes:Page> Is a document node which renders a page. It has a footer property which is basically a Template object. Is there a way to get the prototype name/identifier of the footer property/object?
The prototype/nodeType for the context node is accessible with
q(node).property('_nodeType')
This yields Neos.NodeTypes:Page in this case—that’s clear.
Is there a way to get the prototype of the current object in order to yield V.S:Layout.Footer?
This works for document nodes. But for parts of a document this won’t work, because the nodeType equals the document node’s nodeType. So, I would need the identifier of the prototype of a property that renders a ‘subtemplate’.
prototype(V.S:Default.Layout.Footer) < prototype(Neos.Fusion:Template) {
templatePath = V.S:DocumentTemplatePath.Query
}
# Should load resource://V.S/Private/Fusion/Documents/Default/Default.Layout.Footer.html
# loads resource://V.S/Private/Fusion/Documents/Default/Default.html instead because thats the ${node.nodeType}
But if you want to do that, you should introduce some kind of templatePathPrefix variable in the footer and use THAT in the V.S:DocumentTemplatePath.Query
Then I would need to do that that for every part of a template (Default.Layout.Footer / Default.Layout.Header / Default.Layout.Main / Default.Layout.Sidebar, etc).
prototype(V.S:MyCollection) < prototype(Neos.Fusion:Collection) {
collection = ...
// Select a renderer Prototype with the LayoutMatcher Case
itemRenderer = V.S:LayoutMatcher.Query {
layout.layoutSuffix = 'Item'
default.renderer {
tagName = 'li'
content = ${item.properties.title}
}
}
// Embed the rendered prototype in a layout prototype
@process.embedCollectionInLayout {
expression = V.S:LayoutMatcher.Query {
default.renderer {
tagName = 'div'
attributes.class = ${q(node).property('_nodeType')}
content = ${value}
}
}
}
}
prototype(V.S:LayoutMatcher.Query) < prototype(Neos.Fusion:Case) {
// Select a layout prototype
layout {
@position = 'before default'
// Get the layout. Use the node property in first place, use a context property as fallback
layout = ${q(node).property('layout') ? q(node).property('layout') : layout}
layoutSuffix = 'Layout'
condition = ${this.layout != null && this.layout != ''}
type = ${q(node).property('_nodeType') + '.' + this.layout + '.' + this.layoutSuffix}
}
// Render a Tag as fallback
default {
@position = 'end 9999'
condition = true
// Tag renderer needs to be defined on every use case
renderer = Neos.Fusion:Tag
}
}
This works if I add that MyCollection as childnode via the backend to a document. With layout being TwoColList the Collection would be rendered by rendering MyCollection.TwoColList.Layout and MyCollection.TwoColList.Item. This is very flexible since I can override or extend these prototypes for specific paths/use cases.
But I can’t add MyCollection as fusion property to a document node, e.g.
Because node is the document here, Neos tries to render V.S:MyDocument.TwoColList.Item and V.S:MyDocument.TwoColList.Layout. That makes no sense. That’s why I would need to get the name of the prototype. If add a string variable containing the prototype name would lead too many lines of almost redundant code, that’s actually unnecessary.
I hope this makes it more clear what my use case is and why it makes sense (or why not—then I’m really open to other suggestions).