RFC: Node Templates

Hi all!
I wanted to invigorate this discussion, a year later…
During this year, I have taken the time to think it through, and actually almost daily I would hear a use case for this feature.

In the new UI, we want to implement the node creation wizard right from the start, and it would obviously require node templates to work.

It’s way too early to even think about it now before we have at least a concept for editable nodetype definitions.
However, it would be possible to create this feature already now, with a custom template implementation class. But I don’t see it as a core use case for now, since integrators have to define nodetypes via code, and editors have no influence over it.

I don’t mind extracting the templates themselves into an external file. It has two pros: ability to reuse templates across node type and decluttering NodeTypes.yaml.
But clearly the nodetype definition should be the initiator here, it would declare which template and implementation to use.

NodeTypes.yaml:

'TYPO3.Neos.NodeTypes:Article':
  template: 'TYPO3.Neos.NodeTypes:PressRelease'

And in NodeTemplates.yaml:

'TYPO3.Neos.NodeTypes:PressRelease':
  class: (optional, implements NodeTemplateInterface)
  childNodes:
    mainContentCollection: <-- this is just some key for extensibility
      type: 'TYPO3.Neos:ContentCollection' <-- optional
      name: 'main'
      childNodes:
        helloWorldTextNode:
          type: 'TYPO3.Neos.NodeType:Text'
          properties:
            text: 'Hello world!'

OR, a more low-level alternative, similar to old PR:

'TYPO3.Neos.NodeTypes:Article':
  template:
    class: (optional, implements NodeTemplateInterface)
    settings:
      name: 'TYPO3.Neos.NodeTypes:PressRelease'
      someOtherSetting: 'could be used in custom implementation class'

And in NodeTemplates.yaml:

'TYPO3.Neos.NodeTypes:PressRelease':
  childNodes:
    mainContentCollection: <-- this is just some key for extensibility
      type: 'TYPO3.Neos:ContentCollection' <-- optional
      name: 'main'
      childNodes:
        helloWorldTextNode:
          type: 'TYPO3.Neos.NodeType:Text'
          properties:
            text: 'Hello world!'

I like the first, higher-level approach better.
What do you guys think?

1 Like