Only allow one block type to be created i content area

Vote:
 

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)

#85340
Apr 23, 2014 13:43
Vote:
 

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.

#85365
Edited, Apr 23, 2014 17:54
Vote:
 

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; }

#114646
Dec 16, 2014 23:45
Vote:
 

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.

#114648
Dec 16, 2014 23:50
Vote:
 

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

#114677
Dec 18, 2014 9:25
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.