Copied to clipboard

Flag this post as spam?

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


  • Lachlann 344 posts 626 karma points
    Nov 06, 2013 @ 10:46
    Lachlann
    0

    Umbraco V6.1.6 DocumentType.GetByAlias

    Hello all.

    I am trying to update an old package I created (http://our.umbraco.org/projects/developer-tools/screenmedia-speedy-content-creator) to work with the new API.

    However I use the following line of code to get a list of allowed child content type IDs (AllowedChildContentTypeIDs) which is a method of DocumentType. 

    This appears not to be working anymore and I wondered if any of you knoew what the prefered updated API version of this should be?

    Cheers

    L

  • Kevin Jump 2348 posts 14896 karma points MVP 9x c-trib
    Nov 06, 2013 @ 11:28
    Kevin Jump
    100

    for the v6/v7 API you need to use IContentType for DocumentTypes

    IContentType doctype = ApplicationContext.Current.Services.ContentTypeService.GetContentType(id);
    IEnumerable<ContentTypeSort> allowed = doctype.AllowedContentTypes;
    

    btw . that also works by alias

    IContentType doctype = ApplicationContext.Current.Services.ContentTypeService.GetContentType(alias);
    IEnumerable<ContentTypeSort> allowed = doctype.AllowedContentTypes;
    
  • Lachlann 344 posts 626 karma points
    Nov 06, 2013 @ 12:26
    Lachlann
    0

    Thanks Kevin,

     

    That did the trick

     

    L

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies