Copied to clipboard

Flag this post as spam?

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


  • Kris Dyson 54 posts 79 karma points
    Jul 14, 2010 @ 15:49
    Kris Dyson
    0

    Get all currently published nodes of a root document type

    Hi there, in C# I need to retrieve a list of all published documents / nodes whose document type is a descendent of the document type "SiteSettings".

    What's the best way to go about this?

    I have got as far as...

    foreach (var content in 
    Document.getContentOfContentType(DocumentType.GetByAlias("SiteSettings")).Union(
    Document.getContentOfContentType(DocumentType.GetByAlias("Homepage")).Union(
    Document.getContentOfContentType(DocumentType.GetByAlias("themedPage")).Union(
    Document.getContentOfContentType(DocumentType.GetByAlias("modulePage"))))))
    {
    // do something
    }

     

    I haven't yet found a good way to query for a root document type, so here I'm querying for the root and all it's descendent types explicitly.  However this appears to produce some duplicates and unpublished items.

    thanks for your help

    Kris

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jul 14, 2010 @ 16:00
    Thomas Höhler
    0

    This would be a perfect scenario to use LinQ2Umbraco. Take a look into the sessions of Aaron: http://aaron-powell.com/training-videos

    hth, Thomas

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jul 14, 2010 @ 16:03
    Thomas Höhler
    0

    btw: if yoou use the Documents you are getting all content nodes also the unpublished ones and you are creating many many db calls. I would recommend going to the umbraco.presentation.NodeFactory.Node Namespace which only returns published content and from the memmory not from the db.

    hth, Thomas

Please Sign in or register to post replies

Write your reply to:

Draft