CMS, EPiServer, Episerver 11

How to hide content types from editors in Episerver which you don’t own

In this blog post I’ll show you two ways how to hide content types which you don’t own (meaning the content types are coming from Episerver or 3rd parties). Simple no coding needed and with an initialization module.

Sometimes you might have a need to hide content types from editors but the problem is that you don’t own and have control over the content type definition. If you own the content and don’t want it to be available for editors then it is a simple value that you set in the ContentTypeAttribute, AvailableInEditMode = false.

Why would you have need to hide some content types? For example if you are using Episerver Find it currently also adds the ‘Customized search block’ (there is a request to have this block in a separate NuGet package, so in the future this point might not be valid anymore) but if you have disabled session this block will not work because it currently requires the session tempdata to store something. So now you want to hide this one from editors so that they don’t get confused when it doesn’t work but is available.

Another case when you might want to hide content types from editors is that if you use Episerver Forms and have created custom Forms elements and you don’t want to have the default implementations to be available. Another case might be that you just want to hide some of the default elements like the Captcha implementation (Captcha requires session state but Recaptcha doesn’t) because you don’t have session state enabled.

See the documentation about session state and Episerver. Episerver has a sample Episerver Forms implementation available as NuGet package (includes the Recaptcha) and the source code is available in GitHub.

Hide content type without code

The simplest way to hide a content type from editors without any need for coding is to login to your Episerver instance and navigate to admin view -> Content Type tab. Find the content type that you want to hide from editors and click the content type name in the left panel to select it -> Click the content type ‘Settings’ -> Uncheck the checkbox ‘Available in edit view’ and click save. Content type is no longer available for editors. Remember that you can always revert this change in admin by clicking the ‘Revert to default’ button when viewing a content types settings.

Downside of this is that you need to remember to do this in all of your environments and the setting might change when a NuGet package gets updated.

Hide content type using an intialization module

Another way to hide content types from editors is to do it programmatically using an Episerver initialization module. The module is quite simple: get IContentTypeRepository from the InitializationEngine context, get a content type using its Guid, create a writable clone and set the IsAvailable = false and save using the IContentTypeRepository.

Question is how to get/know the content type Guid? Simple way is to go to Episerver admin view -> Content Type tab -> Select a content type and view its settings.


In the images I have highlighted the content type Guids (you could also use the name, but I’ll use Guids). So this is the easiest way to find out the Guids of the content types another way would be to use your favorite .Net decompiler and find the content types from code and look the at the ContentTypeAttribute values (why would you do it this way? :D).

Next is the code for the initialization module which hides the content type from editors using the Guid (Gist url for the code).

using System;
using EPiServer.DataAbstraction;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.Logging;
namespace AlloyWithFind.Business.Initialization
[ModuleDependency(typeof(EPiServer.Web.InitializationModule), typeof(EPiServer.Forms.InitializationModule))]
public class HideContentTypesInitialization : IInitializableModule
private static readonly ILogger Logger = LogManager.GetLogger(typeof(HideContentTypesInitialization));
/// <summary>
/// Customized search block Guid.
/// </summary>
public static readonly Guid SearchBlockGuid = new Guid("3a263af2-79d9-4275-ad15-3c3187c89870");
/// <summary>
/// Episerver Forms captcha element Guid.
/// </summary>
public static readonly Guid CaptchaBlockGuid = new Guid("0cffa8b6-3c20-4b97-914f-75a624b19bff");
public void Initialize(InitializationEngine context)
// get content types repository
IContentTypeRepository ctRepo = context.Locate.ContentTypeRepository();
HideFromEditors(ctRepo, SearchBlockGuid);
HideFromEditors(ctRepo, CaptchaBlockGuid);
private static void HideFromEditors(IContentTypeRepository repo, Guid contentGuid)
if (repo == null)
throw new ArgumentNullException(nameof(repo));
// get content with Guid (returns null if not found)
ContentType content = repo.Load(contentGuid);
if (content != null)
if (content.IsAvailable)
// make writable clone, hide and save it
ContentType writable = content.CreateWritableClone() as ContentType;
writable.IsAvailable = false;
Logger.Information($"Content type with guid '{contentGuid}' (name: {writable.Name}) hidden from editors.");
catch (Exception ex)
Logger.Error($"Failed to hide content type with guid '{contentGuid}' (name: {content.Name}).", ex);
Logger.Information($"Content type with guid '{contentGuid}' (name: {content.Name}) is already hidden from editors.");
Logger.Warning($"Cannot hide content type with guid '{contentGuid}' because it was not found from content type repository.");
public void Uninitialize(InitializationEngine context)
//Add uninitialization logic

Note! Your initialization module code should take dependency to the modules that “add” these content types you are modifying. In the sample I’ve taken dependency to the ‘EPiServer.Web.InitializationModule’ and ‘EPiServer.Forms.InitializationModule’ to make sure this module is executed after those. It might be enough to have only dependency to ‘EPiServer.Web.InitializationModule’ as the content types should be already synched at this stage (cheat sheet of intialization modules).

So there you have the initialization module to hide content types from your editors.

But there must be other ways too?

Well yes, there are. There are at least two threads at Episerver World where people have asked how to hide the Episerver Forms container or the default Forms elements when custom elements are created.

The presented solution works BUT it uses the DefaultContentTypeAvailablilityService as a base class which is in Episerver internal namespace ‘EPiServer.DataAbstraction.Internal’. The internal namespace indicates that it is not part of semantic versioning and could change without any notice. So be carefull when using something from internal namespaces. I would rather use this initialization module approach 😉

But one thing to note here is that the big difference with having initialization module vs custom content type availability service is that initialization module hides the content type from ALL users but with custom content type availability service you could use the principal object to hide content types per user or role (ListAvailable methods). The default implementation queries create access right for the user to the content.

So if the ‘DefaultContentTypeAvailablilityService’ uses users create access rights to decide is the content type availabe (for the user) it means we have another no coding required option to hide content types or create an initialization module that removes the create content access right from everyone or modifies it so that certain roles only can create the content type.

So I think you should not have the need to create a custom implementation of ‘ContentTypeAvailabilityService’ to just hide content types from ALL users or certain users/roles because you can do that by modifying the content type availability or by configuring the create access rights for the content.

4 thoughts on “How to hide content types from editors in Episerver which you don’t own

  1. Why is it necessary to have the InitializationModule if you could also set the AvailableInEditMode property of the block-type in code directly? For example:

    DisplayName = “Search Block”,
    GUID = “3a263af2-79d9-4275-ad15-3c3187c89870”,
    AvailableInEditMode = false)]
    public class SearchBlock: BlockData { … }

    1. Hi Tim, you missed the point in the blog post, it is about content that you don’t own (you don’t have access to its source code). And as a result you cannot set the AvailableInEditMode = false, which you would use in the ContentTypeAttribute to hide the content type from editors when defining your own content types.

      So repeating the blog post: you can hide a content type from admin view but when the content type is updated (you update a NuGet package and it has updated the version of the assembly where the content type is defined) – the hiding most likely gets reset. So the initialization module is the way to go as it gets executed every time the app is (re)started and ensures the content type stays not available (well one could always go to admin view and make it available) and also the initialization module makes sure the behavior is the same in all your environments and you don’t manually need to remember to hide some content type (which you don’t own).

      Hopefully this clarifies the reason for the initialization module used in this case.

  2. This is exactly what i needed to hide some of the form elements on the site i’m working on. this was a well written and very clear blog post and your code is really nice.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s