Template in ChildNode


(Daniel Toth) #1

I’m trying to use templates to automatically create child nodes within a child node. Please see the code snippet below. When I add Panel1 then Panel2 gets created but not Panel3. When I add Panel2 then Panel3 gets created. I hope it makes sense what I’m trying to achieve. Can you help me by spotting what’s wrong?

'vendor.product:Panel1':
  superTypes:
    'Neos.Neos:Content': TRUE
  ui:
    label: 'Panel1'
  constraints:
    nodeTypes:
      '*': TRUE
  childNodes:
    'panel2':
      type: 'vendor.product:Panel2'


'vendor.product:Panel2':
  superTypes:
    'Neos.Neos:Content': TRUE
  ui:
    label: 'Panel2'
  constraints:
    nodeTypes:
      '*': TRUE
  options:
    template:
      childNodes:
        child1:
          type: 'vendor.product:Panel3'


'vendor.product:Panel3':
  superTypes:
    'Neos.Neos:Content': TRUE
  ui:
    label: 'Panel3'
  constraints:
    nodeTypes:
      '*': TRUE

Thank you in advance,
Daniel


(Daniel Toth) #2

@theilm, does Note Templates support templates of child nodes?


(Daniel Lienert) #3

Hey Daniel,

The template package supports childnodes up to 10 levels, but they are not applied recursively.
That means you need to define the structure of panel2 and its child node panel3 in panel1.

Cheers
Daniel


(Daniel Toth) #4

Thank you for your response but I still couldn’t make it work. This is what I tried, please take a look at it. I’m sure it must be the location of the ‘options’ in panel1…

'vendor.product:Panel1':
  superTypes:
    'Neos.Neos:Content': TRUE
  ui:
    label: 'Panel1'
  constraints:
    nodeTypes:
      '*': TRUE
  childNodes:
    'panel2':
      type: 'vendor.product:Panel2'
      options:
        template:
          childNodes:
            child1:
              type: 'vendor.product:Panel3'


'vendor.product:Panel2':
  superTypes:
    'Neos.Neos:Content': TRUE
  ui:
    label: 'Panel2'
  constraints:
    nodeTypes:
      '*': TRUE


'vendor.product:Panel3':
  superTypes:
    'Neos.Neos:Content': TRUE
  ui:
    label: 'Panel3'
  constraints:
    nodeTypes:
      '*': TRUE

Thank you again,
Daniel


(Daniel Lienert) #5

Hey Daniel,
That was a misunderstanding, seems you talked about auto generated child nodes, while I talked about node templates as kn https://github.com/Flowpack/Flowpack.NodeTemplates. Please have look at the latter. That package should solve your needs. Childnodes doesn‘t work with more than one level AFAIK.

Cheers
Daniel


(Daniel Toth) #6

I’m actually trying to mix auto generated child nodes and node templates.
Panel1 should have an auto generated child node (non-deleteable) Panel2 which should have Panel3 as a template child node (deleteable).
In my original post if I created an instance of Panel2 then Panel3 got automatically created using node templates but when I created an instance of Panel1 then Panel2 got created as a child but not Panel3.
I’m sorry if I wasn’t clear before, I hope this clarifies.
As always, thank you for your help.