+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to programmatically get all content item types?

How to programmatically get all content item types?

4 posts, 1 answered
  1. Bo Chulindra
    Bo Chulindra avatar
    35 posts
    Registered:
    17 Dec 2013
    23 Jan 2014
    Link to this post
    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.
    Answered
  2. Bonny
    Bonny avatar
    58 posts
    Registered:
    11 Nov 2016
    24 Jan 2014
    Link to this post
    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
  3. Atit
    Atit avatar
    10 posts
    Registered:
    27 Feb 2015
    26 Jun 2015
    Link to this post

    Hi Bonny,

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

     Thanks

    Atit

  4. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    06 Dec 2016
    01 Jul 2015
    Link to this post
    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
     
4 posts, 1 answered