[SOLVED] Nesting childNodes inside of ContentCollection

I created a custom node with a childnode and would like to auto-create additional childnodes when creating my node. I’ve got a carousel with a contentCollection that should only carry images. And the first image should be added automatically. I created the following configuration:

    'vendor.SitePackage:Carousel':
  superTypes:
    'Neos.Neos:Content': TRUE
  childNodes:
    carouselItems:
      type: 'Neos.Neos:ContentCollection'
      childNodes:
        firstImage:
          type: 'Neos.NodeTypes:Image'
      constraints:
        nodeTypes:
          'Neos.NodeTypes:Image': True
          '*': false
  ui:
    label: 'Carousel'
    group: 'general'
    icon: 'icon-picture'
    inlineEditable: TRUE

How can this be done?

Hi Erich,

you could use a custom ContentCollection that already has the first image as fixed child node. Like

'Vendor.SitePackage:Carousel.ContentCollection':
  superTypes:
    'Neos.Neos:ContentCollection': true
  constraints:
    nodeTypes:
      '*': false
      'Neos.NodeTypes:Image': true
  childNodes:
    firstImage:
      type: 'Neos.NodeTypes:Image'

And then:

'Vendor.SitePackage:Carousel':
  superTypes:
    'Neos.Neos:Content': TRUE
  childNodes:
    carouselItems:
      type: 'Vendor.SitePackage:Carousel.ContentCollection'

(untested)

Alternatively have a look at https://github.com/Flowpack/Flowpack.NodeTemplates

1 Like

Great!!

Code is now tested and does the job.

Thank you very much!

1 Like