Search code examples
dotnetnuke-module2sxc

2sxc : How to get list of all application Content-Types


Is there any public methode in 2sxc for get all Content-Types?

Or how to get list of all content-types?

(edit / added)

When I get all appTypes (from my answer below) i can access all Fields by this code:

var fieldList = (myType as ToSic.Eav.Data.ContentType).AttributeDefinitions;

the result is Dictionary of AttributeBase with properties: Name, Type, IsTitle, SortOrder,...

But I don't find properties for : REQUIRED, Visible In Edit UI, RowCount,...

Where or how I can access this properties?


Solution

  • I make this code and work OK

      var cache = ToSic.Eav.DataSource.GetCache(null, App.AppId) as ToSic.Eav.DataSources.Caches.BaseCache;
      var allTypes = cache.GetContentTypes().Select(t => t.Value);
      var appTypes = allTypes.Where(t => t.Scope == "2SexyContent").ToList();
    

    Is this the right way?