Try our conversational search powered by Generative AI!

Limit available blocks in "For this site"


Hi, we have a multi-site where each site has some blocks in common and some that are specific to the site. We would like to be able to limit the blocks that can be created under "For this site" (and all subfolders) based on the current site. As it is now all blocks are always shown.

Is there any way this can be done?

Regards, Peter

Edited, Apr 24, 2019 13:30

You can set permissions for the block based on a visitor group. The visitor group can check the URL and see if it matches the site the block can be used for. Don't think there is a built in visitor group criterion to check the URL but that can easily be created: 

Apr 24, 2019 15:07

I'd have been tempted to override the ContentTypeAvailabilityService to return just the content types we wanted but actually that approach of using visitor groups is a better and simpler one.

Apr 25, 2019 10:03

Interesting approach with Visitor Groups, I would never have thought of that.

Is it possible to do this directly in code? We have lots of blocks and several installations (dev, stage, preprod and prod) and we wouldn't want to do it manually for all these instances.

I'll check the ContentTypeAvailabilityService tips as well, thanks

Apr 25, 2019 11:52

In that case you could use a virtual role: in place of a visitor group and assign that to the block model using the Access attribute:

You can implement a custom virtual role by inheriting VirtualRoleProviderBase: 

Apr 25, 2019 12:09

Thanks for all the help. The customer ultimately decided to go the route of setting up virtual groups for each site and llimit the access on the blocks by editing it manually in EPiServer admin (no coding required). Still, I'll keep the other solutions in mind if it ever turns up again :)

Regards, Peter

Edited, Apr 29, 2019 16:33
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.