N2CMS: restricting the number of ContentItems of a certain type below another ContentItem

212 Views Asked by At

I'm using N2CMS, and I have two classes that inherit from ContentItem - say HomePage and NewsPage. NewsPage is set to only appear under HomePage (using the RestrictParents attribute):

[RestrictParents(typeof(HomePage))]

Can I make it so there is a maximum number of NewsPages (in this case 1) below the home page?

1

There are 1 best solutions below

0
On BEST ANSWER

The answer is that you can use the

[RestrictCardinality] 

attribute. In the example I gave in the question, you would use

[RestrictCardinality(ComparableType=typeof(NewsPart), MaximumCount=1)]