In this tutorial, you will learn how to hide Episerver CMS page-type and block-type properties so that they are not editable within the CMS. This approach can be really handy in order to prevent content editors from accidentally making unwanted content changes within the editor. Over the years, I've often needed to define properties to store settings and meta-data. Most of the time these properties should never change. For example, maybe you need to do a content migration and you want to store the pages ID from the original system to make data-mapping easier later on. You would never want to give a content editor the ability to change this value, so what do you do? Luckily, Episerver provides us with some handy attributes to deal with this situation. In this tutorial, you will learn about 3 handy techniques that you can use to restrict properties within the editor 🔥🔥🔥

Hiding A Property

First, you can completely prevent a property from being rendered within the editor. This can be done by decorating a property with the [Ignore] attribute, like this:

Using [Ignore] will still allow for a developer to interact with the property in code, so you can still edit the property in code. A content editor will never be able to see it within the editor!

Making a read-only property

The next attribute in our Episerver toolkit is the read-only attribute, [Editable]. Adding this to a property will show it in the Episerver editor, however, it will be greyed out and the content editor won't be able to edit it:

Hiding A Property In Edit Mode

An alternative way of hiding property within the editor is to the [ScaffoldColumn] attribute. When ScaffoldColumn is set to false, the ScaffoldColumn will hide the property from editors:

Decorating a property as a scaffolded column will mean the content editor will not be able to see the rendered value and it will not be editable in preview mode. The editor will not see the blue editable box around it and they won't be able to click on the property to edit it. The property won't be visible in forms editing mode either.

Using these three techniques, you can hide any property that you desire from the editor. Happy Coding 🤘