Document Constraints unexpected bahaviour?!

Okay this feels like an issue, tell me if I am wrong…

Since I had some troubles with setting up Constraints, the following example below is based on a fresh install with an empty site and the only new code in NodeTypes.yaml is this:

‘Neos.Plain:Test’:
superTypes:
‘TYPO3.Neos:Document’: true
ui:
group: general
label: ‘Test Document’
constraints:
nodeTypes:
‘Neos.Plain:Test’: FALSE
’*’: FALSE

The weird thing here is, that the wildcard doesn’t do anything at all. I was actually aiming for not allowing any child-pages to the Test-page, but having just the wildcard gives me all three options: page, shortcut, Test Document.
Adding the specific ‘Neos.Plain:Test’: FALSE makes at least the option Test Document disapear!?

Oh well defining the contraint like that actually doesn’t let me add the Test Page at all anymore, even on root…

'Neos.Plain:Test':
  superTypes:
    'TYPO3.Neos:Document': true
  ui:
    group: general
    label: 'Test Document'
  constraints:
    nodeTypes:
      'Neos.Plain:Test': FALSE
      'TYPO3.Neos.NodeTypes:Page': false
      'TYPO3.Neos:Shortcut': false
      '*': FALSE

so the wildcard has no effect but the other three lines remove the three available items

The default configuration of DocumentNodeConstraints is this

'TYPO3.Neos:Document':
  constraints:
    nodeTypes:
      '*': FALSE
      'TYPO3.Neos:Document': TRUE

you can find this in the Neos-Package. If you want to deny generic documents but allow some special ones do this.

'Vendor.Site:Document':
  superTypes:
    TYPO3.Neos:Document: true
  constraints:
    nodeTypes:
      'TYPO3.Neos:Document': FALSE
      'Vendor.Site:SpecialDocument': TRUE
1 Like

Hey,

a nasty topic I’ve encountered is that the constraints are very aggressively cached inside the browser. To clear this, run: window.localStorage.clear(); window.sessionStorage.clear() inside the developer toolbar of your browser.

All the best,
Sebastian

Hey!

I keep the Inspector open, clearing the whole Session-Cache there seems to do the job for seeing the changes…

What I want to do:

  1. From the root (Home) downwards only allow specific Document-Types. (no Page or Shortcuts)
  2. Inside the Document-Types only allow specific ContentCollection-NodeTypes for the main-area

How I solved it:

'TYPO3.Neos.NodeTypes:Page':
  constraints:
    nodeTypes:
      # '*': FALSE
      'TYPO3.Neos.NodeTypes:Page': FALSE
      'TYPO3.Neos:Shortcut': false
      'Neos.Plain:Document': true

'Neos.Plain:Document':
  superTypes:
    'TYPO3.Neos:Document': true
  childNodes:
    main:
      type: 'TYPO3.Neos:ContentCollection'
      constraints:
        nodeTypes:
          'Neos.Plain:Element1': true
          '*': false

Also here the wildcard in the ‘TYPO3.Neos.NodeTypes:Page’-constraint doesn’t work… (only setting Page and Shortcuts directly to false does the job) I still don’t really understand why!?

The above solutions seems to work fine, but I am still not sure if this is the proper way to do it?

Also it’s is still not really clear to me what is added by the ‘/TYPO3.Neos.NodeTypes/Configuration/NodeTypes.Documents.yaml’-file besides defining the main-ContentCollection -> what are the defined properties for (what is different between Page to the Document-Type in that sense?)

Thanks for the help!
Robin

I usually use a special root-page and also a vendor page document-type … that looks similar to this:

'Vendor.Site:Document.Root':
  superTypes:
   'Vendor.Site:Document.Page': TRUE

'Vendor.Site:Document.Page':
   superTypes:
     'TYPO3.Neos:Page': TRUE
  constraints:
    nodeTypes:
      'TYPO3.Neos:Document': FALSE
      'Vendor.Site:Document.Root': FALSE
      'Vendor.Site:Document.Page': TRUE
      'TYPO3.Neos:Shortcut': TRUE

To create the root-document i usually manipulate the autocreated site.xml

Beware of typos … I wrote this from memory

1 Like