Copied to clipboard

Flag this post as spam?

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


  • Marty 3 posts 23 karma points
    Mar 26, 2014 @ 00:26
    Marty
    0

    Getting Content of a certain DocType starting a specific node.

    I have am using this part of the API to get content of a specifc doctype

    IContentType attendanceContentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType("attendance")

     

    I don't want all of them that exist in my system but those that are under a particular node instead.

     

    Thanks

  • Alan Howlett 19 posts 54 karma points
    Mar 26, 2014 @ 12:00
    Alan Howlett
    0

    What about using something like this:

    IContentType attendanceContentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType("attendance")
    var items = ApplicationContext.Current.Services.ContentService.GetContentOfContentType(attendanceContentType).Where(c => c.ParentId == {specific Id})

     

  • Marty 3 posts 23 karma points
    Mar 26, 2014 @ 17:01
    Marty
    0

    That is close but not quite what I need.

    The main issue is that the doctype I am looking for is not immediately under the parent. otherwise the .Where would work

    Root

    Location

    Meeting

    Attendee 1

    Attendee 2

    I am looking to get attendees for all meetings at a particular location

    Thanks again

  • Alan Howlett 19 posts 54 karma points
    Mar 26, 2014 @ 17:49
    Alan Howlett
    0

    Ah, ok!  How about trying this instead:

                    IContent node = ApplicationContext.Current.Services.ContentService.GetById({specific Id});

                    ApplicationContext.Current.Services.ContentService.GetDescendants(node).Where(c => c.ContentType.Alias == "attendance");

    Rgrds
    A
  • Marty 3 posts 23 karma points
    Mar 26, 2014 @ 18:44
    Marty
    0

    Perfect!!

    Thanks

  • Charles Afford 1163 posts 1709 karma points
    Mar 26, 2014 @ 20:25
    Charles Afford
    0

    Marty where abouts are you trying to get this is?  a razor file?  If so you will be better of going for IPublishedContent.

    Charlie

Please Sign in or register to post replies

Write your reply to:

Draft