Try our conversational search powered by Generative AI!

Globally restrict block in all content areas

Vote:
 

We are creating a new non-visual block (i.e. no view) which will solely be referenced in other blocks as a property and would like to globally remove it from the list of available blocks when creating a new block in content areas. I know the AllowedTypes attribute can be used for this on a content area by content area basis, but I am hoping to find a way to apply it to all content areas without manually decorating each individual one in our entire codebase.

#217020
Feb 13, 2020 4:20
Vote:
 

You can take a look at the ContentTypeAvailabilityService. Should be fairly easy to inherit DefaultContentTypeAvailabilityService and filter that block type.

#217025
Feb 13, 2020 7:26
Vote:
 

Here is an answer

https://world.episerver.com/forum/legacy-forums/Episerver-7-CMS/Thread-Container/2013/3/Block-only-as-property-disabled-as-shared-block/

Example of use:

[ContentType(AvailableInEditMode = false)]
public class B : BlockData
{
    public virtual string Title { get; set; }
    public virtual XhtmlString Text { get; set; }
}
#217026
Feb 13, 2020 7:34
Vote:
 

Of course, how could I forget about that? :)

#217028
Feb 13, 2020 8:37
Praful Jangid - Feb 13, 2020 8:41
I reminded you too then :)
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.