What would be the best way limit the number of blocks allowed to be placed inside a ContentArea? Would this need to be a custom control or is there a way to limit this in the admin system?
I'm quite new to EPiServer, so if someone has some example code, that would be fabulous :-)
You could add a validator. See an example for ContentAreas in this thread:
This example validates the type of Content but you could easily change it to number of Blocks
Thanks Alf. That seems like it could work!
How would I keep track of how many blocks there are in the ContentArea, using that example as a starter?
You can look at the ContentArea.Contents for each Content/Block/Page added.
Use Linq methods such as .Count() to find out the amount.
If you want to re-use this validation on several Page Types, you can create a separate validator.
See more at http://world.episerver.com/Blogs/Alexander-Haneng/Dates/2013/1/Limiting-a-Page-Property-to-a-specific-Page-Type-in-EPiServer-7/
The value should be parsed to ContentArea instead of PageReference as is used in the example.
Thanks Alf, I'll check it out :-)
Is this still the best solution as of EPiServer 8?