Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andre Sousa 15 posts 145 karma points
    Sep 09, 2016 @ 09:39
    Andre Sousa
    0

    Add New Tab to a Document Type

    Hi all,

    I'm trying to create and add a new virtual tab, with properties and stuff, to an existing document type.

    The problem is that the methods i'm trying to use are deprecated and i'm having some errors too.

    var dt = DocumentType.GetByAlias("MyDocumentTypeAlias");
    int tabId = dt.AddVirtualTab("ContentTab");
    var pt = dt.AddPropertyType(new DataTypeDefinition(-49), "ContentTab", "Content Tab");
    dt.SetTabOnPropertyType(pt, tabId);
    dt.Save();
    

    Is there a more recent/updated solution?

    Thanks in advance,

    Andre Sousa.

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Sep 09, 2016 @ 12:16
    Sebastiaan Janssen
    100

    This is more recent and relevant:

    var contentTypeService = UmbracoContext.Current.Application.Services.ContentTypeService;
    var contentType = contentTypeService.GetContentType("MyDocumentTypeAlias");
    var tab = new PropertyGroup { Name = "ContentTab", SortOrder = 100 };
    contentType.PropertyGroups.Add(tab);
    contentTypeService.Save(communityContentType);
    
  • Andre Sousa 15 posts 145 karma points
    Sep 09, 2016 @ 12:47
    Andre Sousa
    0

    Thanks man!

    I think this is the way to go.

    Thank you for the reply Sebastiaan.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies