Unfortunately, there is a bug which allows the editors to create any block from the "quick link" in the content area. But the attribute AllowedTypes stops editors from using drag-n-drop, this works for ContentReference and PageReference as well.
Hi Sara, you can allow only one kind of block with:
[Display(
Name = "Header",
Description = "Place here the Header Text Block",
GroupName = SystemTabNames.Content,
Order = 1)]
[Editable(true)]
[AllowedBlockTypes(new[] { typeof(HeaderOfferTypeBlock) })]
public virtual ContentArea HeaderTextBlock { get; set; }
Alfredeo, that will unfortunately not stop editors from creating blocks from the "quick link". Your code will only stop editors from drag-n-dropping blocks to the content area.
However, EPiServer is working on a solution where the "quick link" will work as well.
Before the arrival of the AvailableTypesAttribute I had an ValidationAttribute class with the same name. I've since changed it name but still use it to restrict the types allowed in content areas.
http://world.episerver.com/code/dannymurphy/contentarea-item-restrictions/
regards,
Danny
Can I limit the creation of blocks to just one type of block when I create a new block locally from the content area? (not drag and drop)