I don't see anything in the training materials or documentation for what I'm trying to do.
I would like to create a page with a list of ContentAreas that the user can specify how many areas they want and blocks inside each. I'd also like to include restrictions on how many areas and blocks are allowed. Here is the code example:
[SiteContentType(DisplayName = "Fun Page",
GroupName = Global.GroupNames.Default]
public class ExamplePage : BasePage
{
[Display(Name = "First Position Block",
GroupName = Global.GroupNames.Default,
Order = 60)]
[AllowedTypes(typeof(BaseBlock))]
[ItemRange(1, 10)]
[ListItems(2)]
public virtual List<ContentArea> BlockSections { get; set; }
}
I'm getting an error stating my property is not an allowed type on the class:
The property 'BlockSections' on the content type 'ExamplePage' has a type that does not support the AllowedTypesAttribute.AllowedTypes is only supported on properties of types: 'ContentReference', 'ContentArea', 'IEnumerable`1'.
When I remove the [AllowedTypes] attribute I get a different error:
EPiServer.Core.TypeMismatchException: Type 'System.Collections.Generic.List`1[[EPiServer.Core.ContentArea, EPiServer, Version=11.14.2.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]]' could not be mapped to a PropertyDefinitionType
Is what I'm trying to do possible or is there a better way? The only way I can get this to work is if I create multiple ContentArea properties which is not maintainable.
Thanks.