November Happy Hour will be moved to Thursday December 5th.

Limit available blocks in "For this site"

Vote:
 

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

#203460
Edited, Apr 24, 2019 13:30
Vote:
 

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: https://world.episerver.com/documentation/developer-guides/CMS/personalization/developing-custom-visitor-group-criteria/ 

#203468
Apr 24, 2019 15:07
Vote:
 

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.

#203492
Apr 25, 2019 10:03
Vote:
 

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

#203497
Apr 25, 2019 11:52
Vote:
 

In that case you could use a virtual role: https://world.episerver.com/documentation/developer-guides/CMS/security/Virtual-roles/ in place of a visitor group and assign that to the block model using the Access attribute: https://world.episerver.com/documentation/developer-guides/CMS/Content/Attributes/

You can implement a custom virtual role by inheriting VirtualRoleProviderBase: https://world.episerver.com/documentation/Class-library/?documentId=cms/11/1B4BB538 

#203498
Apr 25, 2019 12:09
Vote:
 

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

#203610
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.