Copied to clipboard

Flag this post as spam?

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


  • Sören Deger 733 posts 2844 karma points c-trib
    Mar 12, 2015 @ 06:30
    Sören Deger
    0

    Get parent content types with ContentTypeService?

    Hi all,

    is there a way to get all parent content types of a given content type?

    Example:

    var docType = Services.ContentTypeService.GetContentType(id);

    With the code above I get the content type of the specific content type id. But how I can get all parents of this? I have the requirement to get all properties of a specific content node. But if a content type has parents I only get the properties of the specific content type:

    foreach (var prop in Services.ContentTypeService.GetContentType(id).PropertyTypes.OrderBy(p => p.Name))

    Is there a simple way to get the PropertyTypes recursive?

     

    Thanks in advance.

    Best,

    Sören

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 12, 2015 @ 08:41
    Dave Woestenborghs
    0

    Hi Soren,

    Do you mean the properties of the parent item in the document tree ?

    Or do you mean getting properties of the master document type ?

    Dave

  • Sören Deger 733 posts 2844 karma points c-trib
    Mar 12, 2015 @ 08:42
    Sören Deger
    0

    Hi Dave,

    the last one: getting properties of the master document type.

     

    Best,

    Sören

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 12, 2015 @ 08:47
    Dave Woestenborghs
    100

    Hi Soren,

    Normally you would get all properties including the one from master documenttypes if I am correct. Otherwise you can try to figure out which master doctype is set and get the properties from that.

    Dave

  • Sören Deger 733 posts 2844 karma points c-trib
    Mar 12, 2015 @ 09:06
    Sören Deger
    0

    Hi Dave,

    no, I get only the properties from the current documenttype. But I get the id of the parent document type with this and can use this to get the properties of the master document type:

    var docType = Services.ContentTypeService.GetContentType(id).ParentId;

    It would however go even easier.

    But thank you for bringing me in the right direction.

     

    Best,

    Sören

     

  • Avraham Kahana 22 posts 56 karma points
    Apr 20, 2015 @ 11:29
    Avraham Kahana
    0

    Was going to post a thread asking for the same... No answers ? Not possible to get a content type parent type's properties? (Well, I was looking for a way do access "description", which I just learned that it is not really a content type property, so no questions from my side anymore)

Please Sign in or register to post replies

Write your reply to:

Draft