Add new ContentCollection

Hello community,

I am new to NEOS and trying to get into it. Currently I work
on some demo site in order to know how to develop with NEOS for our customers.

I figured out I have some problems with adding a new content collection (as a sidebar in the layout; basically the example in the NodeTypes.yaml)

When I comment out the example I get the following definition for the additional content collection:

‘Neos.NodeTypes:Page’:
childNodes:
‘sidebar’:
type: ‘Neos.Neos:ContentCollection’

But in edit mode in NEOS, there wont be an additional content collection.
Am I wrong that it must be there or is there any configuration besides I also have to do in order to put content in a sidebar? In the layout I also did something like this:

<div class="content">
			{content.main -> f:format.raw()}
		</div>
		<div class="rechtespalte">
			{content.sidebar -> f:format.raw()}
		</div>

Regards,

Kevin

Hi @kevin47163,

I think you’re missing the fusion part in what you are trying to acheive.
Something like:

prototype(Neos.Neos:Page) {
head {
    [...]
}
body {
[...]
    content {
        sidebar = Neos.Neos:ContentCollection {
            [...]
        }
}
[...]

}

Check into the Root.fusion file of your site package.

Hope it helps,
Nicola

1 Like

Hey @ilCerchiari,

that worked out pretty easily. Thank you very much!

I added a “sidebar” to my site, that works.
But since I try to do exactly the same with a “footer”, it won’t.

When adding the sidebar, there was the same error message as now with the footer, but by running the command mentioned in the error message the problem got solves and “sidebar” appeared in the structure tree.
Running the flow command again to solve the problem with footer does nothing…

An exception was thrown while Neos tried to render your page

No content collection of type Neos.Neos:ContentCollection could be found in the current node (/sites/testseite) or at the path “footer”. You might want to adjust your node type configuration and create the missing child node through the “flow node:repair --node-type Neos.NodeTypes:Page” command.

pageNeos.Neos:Page/ bodyNeos.Fusion:Template/ content/ footer/ __meta/ context/ node<>/

For a full stacktrace, open Data/Logs/Exceptions/20170307180411659650.txt

In fact, I ask myself If I even did it right the first time, when there will be this message everytime I add a ContentCollection. And why do I have to run the flow command for that?

Hi @kevin47163,

Could you post the relevant part of your fusion file?
What’s the suggested command (I don’t remember the suggestion atm) ? Is it ./flow node:repair (with some options)?

Thanks,
Nicola

Hi @ilCerchiari,

Yes, it’s “flow node:repair --node-type Neos.NodeTypes:Page”

Let’s only focus on the sidebar thing. I removed any footer-stuff for simplicity.

My NodeTypes.yaml:

'Neos.NodeTypes:Page':
  childNodes:
    'sidebar':
      type: 'Neos.Neos:ContentCollection'

My Root.fusion

content {
    // The default content section
    main = Neos.Neos:PrimaryContent {
          nodePath = 'main'
    }

    sidebar = Neos.Neos:ContentCollection {
          nodePath = 'sidebar'
    }
}

I’m not Core Team member or Neos Guru of sort (they could give you more insight on this topic) but from what I see you should better use a flowQuery to query ContentRepository and retrieve the correct node (i.e. ContentCollection), check this example:

sidebar = Neos.Neos:ContentCollection {
      nodePath = ${q(node).find('sidebar').property('_path')}
      collection = ${q(node).children('sidebar').children()}
}

This snippet will retrieve the ContentCollection(sidebar) and its children defined in the node you are navigating into. If you want those contents to be inheritable, i.e. same content in every page from homepage, you could change node with site

As for the node.repair command is needed when you already have nodes in your ContentRepository and you want to apply to them some modification, it is a sort of migration in this case.
BTW it has a lot of other features, therefore I suggest to run a ./flow help node:repair to check them out, pretty helpful.

Hope it helps you achieve what you are looking for and if I said something wrong I hope the Gurus :wink: can correct me.

Bests,
Nicola

As I always found myself in this thread when searching about my problem, I could imagine that this is a good place to ask.

I just set up Neos and tried the same: Setting up a page layout with a new content collection (i.e. “sidebar”). For this, I added the following configuartion to NodeTypes.yml:

'Vendor.DemoPage:Sidebar':
  ui:
    label: Sidebar layout
    icon: icon-globe

  superTypes:
    'Neos.NodeTypes:Page': TRUE

  childNodes:
    sidebar:
      type: 'Neos.Neos:ContentCollection'
      position: 'end'

This will render the layout and subpageLayout fields properly as expected.

Inside the provided Root.fusion template, I simply added the following block:

sidebar < page {
    body.content {
        sidebar = Neos.Neos:ContentCollection {
            nodePath = ${q(node).find('sidebar').property('_path')}
            collection = ${q(node).children('sidebar').children()}
        }
    }
}

Afterwards, I added

{content.sidebar -> f:format.raw()}

to the default template. This yields the error message

No content collection of type Neos.Neos:ContentCollection could be found in the current node and no node path was provided. You might want to configure the nodePath property with a relative path to the content collection.

What am I missing here?