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

StackOverflow https://stackoverflow.com/questions/14525673

  •  05-03-2022
  •  | 
  •  

Domanda

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?

È stato utile?

Soluzione

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)]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top