Try our conversational search powered by Generative AI!

Custom AvailableContentTypes attribute

Vote:
 

Does anyone know if we can create a custom attribute to show/hide a page type that depends on a custom condition? I would like to have an attribute like:

[CustomAvailableContentType]
public class ProductPage : StandardPage, IHasRelatedContent
{
}


#205364
Jul 09, 2019 1:36
Vote:
 

Hi Francisco,

Yep. I wrote a blog post about a similar scenario. The post is about feature switching based on language but, as I say at the end, you can use any custom logic you like to decide whether to show the content type or not:

https://world.episerver.com/blogs/paul-gruffydd/dates/2019/3/language-based-feature-switching/

In short, you'd need to create an implementation of ContentTypeAvailabilityService which checks for the attrtibute and applies the relevant logic to determine whether the content type should be shown.

#205370
Jul 09, 2019 10:23
Francisco Quintanilla - Jul 09, 2019 23:58
Excellent post!
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.