Disabling a child node for all pages (good or bad idea?)

Hi everybody,

I am maintaining a project with individual document types. Now I had a problem and found a solution for it, but am not sure if it’s a good idea or bad practice.

We created a new document node “article folder” which can be placed anywhere in the document tree. And another document node, let’s call it “article”, which must not be placed anywhere else than inside “article folder”.

The point I’d like to discuss is, that I do not disable “article” as children in my individual abstract document type, but I’m doing this in Neos.Neos:Document:

Neos.Neos:Document:
  constraints:
    nodeTypes:
      Vendor.Package:Document.Article: false
Vendor.Package:Document.ArticleFolder:
  superTypes:
    Vendor.Package:Document.Abstract.Document: true
  constraints:
    nodeTypes:
      Vendor.Package:Document.Article: true

Why?
Because my main goal is, that “article” will never be allowed inside any other page than in my “article folder”. At the moment, I could also disallow it in my abstract document node. But maybe if I would integrate any third party plugin in the future, which does not know about my abstract document node, it probably could bring new document types, which extend the default Neos.Neos:Document - and with my solution, it automatically would not allow “article” below it.

Why not?
I don’t know. That’s why I’m asking. I always read and hear to not modify default node types, but always extend them and build own abstract nodes.

Maybe any more experienced Neos user could give me some feedback, if I had a good or a bad idea?

Hi, that’s similar to what we recommend as best practice.

So a great reliable way is to override the constraints and disallow everything like this:

Neos.Neos:Document:
  constraints:
    nodeTypes:
      '*': false
      'Vendor.Package:Constraint.Subpage': true

Then you introduce a constraint nodetype

Vendor.Package:Constraint.Subpage:
    abstract: true

And use it like this to allow a certain document type:

Vendor.Package:Document.Page:
   superTypes:
      Neos.Neos:Document: true
      Vendor.Package:Constraint.Subpage: true

This way you control in the parent nodetype what general type of things are allowed. And allow individual nodetypes by adding the constraint to them as super type.

I thought there was a tutorial somewhere, but can’t find it right now.

https://docs.neos.io/cms/manual/content-repository/node-constraints

:wink:

I meant the specific use of constraint nodetypes. That’s not on that page.
And Roland’s tutorial uses restriction types instead of constraint types.

Thanks for your reply. So in short you say: “Disabling node types in Neos.Neos:* is absolutly fine, but enabling should be done in abstract node types” - Did I get that correctly?

It’s best to disable everything at the top most level. Like Neos.Neos:Document or Neos.Neos:ContentCollection.
And then enable specific abstract “constraint” types in your Pages or containers and assign them to your individual types.

1 Like