Tags: Egenskaper

Property count per tab in Episerver edit mode

Using an EditorDescriptor, it is possible to add a property count to each tab in edit mode.

[EditorDescriptorRegistration(TargetType = typeof(ContentData))]
public class PropertyCountDescriptor : EditorDescriptor
{
  public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
  {
    foreach (var property in metadata.Properties.Cast<ExtendedMetadata>())
    {
      if (property.GroupSettings != null)
      {
        property.GroupSettings.Title += 
          " (" + 
          metadata.Properties.Cast<ExtendedMetadata>()
          .Count(x => property.GroupName == x.GroupName && x.ShowForEdit) + 
          ")";
       }
    }
  }
}

Now, we can easily see how many properties that reside in each tab.

A list of tabs, each with a number in parentheses

Found this post helpful? Help keep this blog ad-free by buying me a coffee! ☕