Are you tired of Administrators changing your Content Types and breaking your web site?
Fear not, I’ve found a cool hidden gem that allows you to disable fields when editing Content Types in Admin Mode – the EPiServer.DataAnnotations.AdministrationSettings attribute.
It is simply added to your Content Type Class
[AdministrationSettings( [bool CodeOnly], [ContentTypeFields ContentTypeFields], [string GroupName], [int Order], [PropertyDefinitionFields PropertyDefinitionFields], [bool Visible])] public class StandardPage : PageData { ... }
With the AdministrationSettings attribute you can edit the following parts
How it is displayed
GroupName
The GroupName is used to group your Content Types in Admin mode.
Visible
If you simply want to hide your Content Type in Admin Mode.
Order
An integer where you define the sort order inside the Group.
Disable Administrator accessability
CodeOnly
If you simply want to disable changes for the entire Content Type.
PropertyDefinitionFields
This is an enum flag that only enables certain fields on the Edit Property view for the Content Type.
Note that if you create a Property, it cannot be saved unless you allow the required fields.
- None
- Type
- Name
- PropertySettingsControl
- DefaultValue
- Required
- Searchable
- LanguageSpecific
- DisplayEditUI
- EditCaption
- HelpText
- Tab
- FieldOrder
- All
ContentTypeFields
Same as PropertyDefinitionFields but with the fields for your Content Type.
- None
- Name
- Description
- DisplayTemplates
- SortOrder
- DisplayName
- AvailableInEditMode
- ACL
- DefaultValues
- AvailablePageTypes
- All
Summary
This attribute will help you organize your Content Types and to disable editing capabilities for Content Types you really don’t want an administrator to mess with. But use it wisely!
Having many and small groups can make a mess for the administrator and yourself.
Nice one.
Nice!
Good idea