How to programmatically get all content item types?

Posted by Community Admin on 04-Aug-2018 15:42

How to programmatically get all content item types?

All Replies

Posted by Community Admin on 23-Jan-2014 00:00

I would like to be able to write code that can fetch all the content item types in my Sitefinity app. For example, I'd like to get a list of the types Event, News, GenericContent, etc (every type that's listed under Content > Types of Content in the administrative view). Is that possible?

My alternative is to hard-code the types. That may be okay if it's impossible to fetch them dynamically.

Posted by Community Admin on 24-Jan-2014 00:00

Hi,

At this moment there are no way to do this. The modules are in no way dependable to each other. We are in progress of creating an API to get all types of content in Sitefinity, but at this point it is internal - mabe it will be oppened in some of the next releases.
I think that the only solution for now is to hardcode the content types.

Regards,
Bonny
Telerik

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 26-Jun-2015 00:00

Hi Bonny,

 I am usingSitefinity 8.0 right now. Is it possible to get list of content types with Sitefinity 8.0?

 Thanks

Atit

Posted by Community Admin on 01-Jul-2015 00:00

Hi Atit,

You can get the types through the MetadataManager. Here is a sample code for your reference:

var manager = MetadataManager.GetManager();
 
var types = manager.GetMetaTypes();
 
List<string> allTypes = new List<string>();
 
foreach (var type in types)
string fullTypeName = type.FullTypeName;
allTypes.Add(fullTypeName);


Regards,
Sabrie Nedzhip
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed