jahia

Allow contributors to add limited number of a node


I want to allow my contributors to add a limited number of a node in Edit Mode. Here's what I have right now in my definitions.cnd:

[jnt:parent] > jnt:content, jmix:basicContent, mix:title
 - intro (string, richtext)
 + * (jnt:child)

This allows contributors to add as many node child they want. I want to limit that number to 2. I tried + 2 (jnt:child) but that didn't change a thing.

How to achieve my goal?


Solution

  • It's not possible to specify how many child you want to add.

    As workaround, it's possible to do that :

    [jnt:parent] > jnt:content, jmix:basicContent, mix:title
     - intro (string, richtext)
     + firstChild (jnt:child)
     + secondChild (jnt:child)
    

    Here, contributors would only be able to add these 2 node "child", with these names.