SaaS CMS has officially launched! Learn more now.

Only allow a block in one specific content area

Vote:
 

I have a situation where I have a block that should only appear in a few specific content areas. Meaning I want to prevent it from being used anywhere else. I know you can use the [AllowedTypes(...)] attribute on specific ContentArea properties to allow or restrict types, but short of setting [AllowedTypes(...)] with my particular block type as restricted on every single ContentArea in the entire solution, is there some way for me to indicate that the default behavior for this block is for it to be restricted?

#189308
Mar 15, 2018 8:58
Vote:
 

Some ideas:

Use allowed types with an interface so you only need to decorate where you want the block to be used: https://world.episerver.com/blogs/Ben-McKernan/Dates/2015/2/the-new-and-improved-allowed-types/

Implement an IValidator interface that checks the content areas on a page and looks for your block type and warn users appropriately: https://www.david-tec.com/2012/06/EPiServer-7-Preview---IValidator-interface/

David

#189310
Mar 15, 2018 9:47
Vote:
 

I may be a little late to this game, but I use eGandalf's plugin for doing this. https://github.com/egandalf/eGandalf.Epi.Validation

You can grab it from the Epi nuget package manager.

#197483
Oct 03, 2018 23:18
* 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.