Get prototype of a current property/object

Is it possible to get the prototype name/identifier of a property in a specific path?

This is my structure:

root<Neos.Fusion:Case>/
 default<Neos.Fusion:Matcher>/
  element<Neos.NodeTypes:Page>/ <-- ${node}
   body<Neos.Fusion:Renderer>/
    element<V.S:Layout>/
     footer<V.S:Layout.Footer>/ <-- prototype(V.S:Layout.Footer) < prototype(Neos.Fusion:Template)

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?

Why would you ever need that?

@christianm
To dynamically load fluid template files.

prototype(V.S:DocumentTemplatePath.Query) < prototype(Neos.Fusion:Array) {
  @ignoreProperties = ${['nodeTypeIdentifier']}
  nodeTypeIdentifier = ${String.split(node.nodeType,':')}
  resource = 'resource://'
  package = ${this.nodeTypeIdentifier[0]}
  resourcePath = ${'/Private/Fusion/Documents/' + String.split(this.nodeTypeIdentifier[1],'.')[0] + '/'}
  nodeType = ${this.nodeTypeIdentifier[1]}
  extension = '.html'
}

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}

I don’t think that’s a good idea actually.

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

Why?

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).

I would need that for components, too.

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.

prototype(V.S:MyDocument) < prototype(Neos.NodeTypes:Document) {
collection = V.S:MyCollection {
@context.layout = ‘TwoColList’
}

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).

An object does store it’s name in fusionObjectName (see https://neos.github.io/neos/3.0/source-class-Neos.Fusion.FusionObjects.AbstractFusionObject.html#34-39) Is there any way to access this in Fusion?