Snake Eyes
Snake Eyes

Reputation: 16764

Get Umbraco tabs with C#

I tried to get available tabs in Umbraco (7.4.2) using the following code:

DocumentType dt = new DocumentType(1051); //id of documenttype
foreach (ContentType.Tab x in dt.getVirtualTabs)
{
    ...
}  

but ... DocumentType is obsolete and when I tried to call getVirtualTabs then I got exception and I cannot use it.

How to get available tabs ?

Upvotes: 1

Views: 221

Answers (1)

Jannik Anker
Jannik Anker

Reputation: 3425

Look here: https://our.umbraco.org/Documentation/Reference/Management/Models/ContentType - in part due to the new composition possibilities it looks like a lot has changed in this area :-)

It should be as easy as

var contentType = contentTypeService.GetContentType(1051);

foreach (PropertyGroup pg in contentType.PropertyGroups)
{
   ...
}

EDIT

For the ContentTypeService look here: https://our.umbraco.org/documentation/Reference/Management/Services/ContentTypeService

Upvotes: 3

Related Questions