Views: 12521
Number of votes: 9
Average rating:

Typed tabs/groups

Currently in the typed model you are limited to defining sort order on individual content types and properties. The order defined then indirectly defines in which order groups are displayed when creating new content, and in which order the tabs are shown when editing content in the forms view. Normally you define groups as a list of constants that you use in the DisplayAttribute:

[ContentType(GroupName=GroupNames.News, Order=1)]
public class ArticlePage : PageData
{
  [Display(GroupName = GroupNames.Contact)]
  public virtual ContentReference Image { get; set; }
}

public static class GroupNames
{
   public const string News = "News";
   public const string Contact= "Contact";
}

In CMS 8 we are adding support for defining order and required access on the groups themselves. Just decorate the class:

 [GroupDefinitions]
public static class GroupNames
{
   [Display(GroupName="MyNews", Order=1)]
   public const string News = "News";
   [RequiredAccess(AccessLevel.Publish)]
   public const string Contact= "Contact";
}

Groups that do not have any order defined will fallback to the indirect sorting and will have sort index set to -1. It is also possible to override built-in groups to change sort order, for example:

[GroupDefinitions]
public static class GroupNames
{
    [Display(Order = 1000)]
    public const string Content = SystemTabNames.Content;
}


See SDK article Grouping content types and properties for more details.

Feb 11, 2015

( 2/11/2015 2:17:37 PM)

Nice!

Eric
( By Eric, 2/11/2015 2:29:46 PM)

Nice feature. So when is the release of CMS 8? :)

( 2/11/2015 2:47:55 PM)

@Eric Before Tết I hope :)

Eric
( By Eric, 2/11/2015 3:24:44 PM)

Ah good to know :)

Johan Book
( By Johan Book, 2/11/2015 10:14:56 PM)

+1

Henrik Fransas
( By Henrik Fransas, 2/24/2015 10:46:37 AM)

Great, a feature I've been waiting for a long time :)

Josef-Ottosson
( By Josef-Ottosson, 4/4/2015 12:17:41 PM)

Really nice!

Sriram raja
( By Sriram raja, 6/3/2020 7:56:03 AM)

how to restrict user access to all tabs above highlited one. There are many tabs. We need to have separate access for each tab access based on user group like admin editor etc. can you please post a code for it:)

Please login to comment.