Tags: Egenskaper

What’s in your head?

In Episerver CMS, you are probably familiar with the concept of grouping properties into tabs. You may place your own properties in the existing tabs (Content, Settings etc) or create your own tabs with descriptive names.

You may, however also tamper with the special tab PageHeader!

Episerver all properties view with the PageHeader area highlighted

What if editors never use the property «Display in navigation», but very often need to use «Update modified date»? Wouldn’t it be more practical if they switched places? We can do that!

An illustration of switching places of

We simply add an EditorDescriptor, telling the properties that they do belong to another tab.

[EditorDescriptorRegistration(TargetType = typeof(ContentData))]
public class MoveInAndOutOfHeadEditorDescriptor : EditorDescriptor
{
   public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable attributes)
   {
      foreach (var modelMetadata in metadata.Properties)
      {
         var property = (ExtendedMetadata)modelMetadata;
         if (property.PropertyName == "ichangetrackable_setchangedonpublish")
         {
            property.GroupName = SystemTabNames.PageHeader;
            property.Order = 12;
         }
         if (property.PropertyName == "PageVisibleInMenu")
         {
            property.GroupName = SystemTabNames.Settings;
            property.Order = -76;
         }
      }
   }
}

The final result will look like this:

The result after the properties have switched places