Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Restrict available create pagetype for difference sites under same root.

Vote:
 

Hello,

My customer has using epi 10 and they have three sites that using the same root. For example

Root

  • Site 1
    • Pagetype1
    • Pagetype2
    • Pagetype3
  • Site 2
    • Pagetype1
    • Pagetype2
    • Pagetype3
  • Site 3
    • Pagetype1
    • Pagetype2
    • Pagetype3

Then Site 2 and 3 not allow to create Pagetype3. How I could do that in programmatically?

Thanks!

/Katharina

#187323
Jan 19, 2018 10:55
Vote:
 

Hi Katharina,

If you share Pagetype1 and Pagetype2 across all sites, this functionality isn't supported through the standard AvailableContentTypes attribute. If you want to use AvailableContentTypes, you could consider adding additional content types to each site that extend your current types and simply set different AvailableContentTypes attributes on each class. You'd have to convert existing content to the new types, which is a bit of a headache, but it would allow you to use the attribute.

Alternatively, you would have to implement your own ContentTypeAvailabilityService, which is the service that Episerver calls when it renders the interface of available types during content creation. The recommended approach is to make your own implementation of this abstract class, implement GetSetting / ListAvailable / IsAllowed and register it on the IoC container for usage instead of the default implementation. You can implement custom logic for filtering down the types based on the current site context.

Here is an example Mattias Olsson put together that does something similar to what you are trying to achieve, although it overrides the default implementation (DefaultContentTypeAvailablilityService), which isn't recommended since its internal / could change at anytime.

https://getadigital.com/no/blogg/controlling-content-type-and-property-availability-in-multi-site-solutions/

Hope this helps,

/Matt

#187357
Jan 19, 2018 18:17
* 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.