Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Feb 15, 2010 @ 12:37
    Lee
    0

    Get List Of Unpublished Nodes Of Specific DocType

    Been having a play with the API and need to create a usercontrol that displays a list of unpublished nodes with a specific DocType - I then want to bind to a repeater or dataGrid?

    Anyone done anything similar?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 15, 2010 @ 13:02
    Dirk De Grave
    1

    Hmm, not sure if I'd want this in the frontend, but if you're using this from the backend, have a look at Richard's maintenance project, it'll help identifying the unpublished nodes, and may want to peek into the source to find out how he's done it.

    Hope this helps.

    Regards,

    /Dirk

     

  • Lee 1130 posts 3088 karma points
    Feb 15, 2010 @ 13:07
    Lee
    0

    Thanks Dirk, I had a look at that but Richard doesn't use the API to get them he makes a direct call to the DB - Was wondering it this was possible using the API?  If not I'll have to use Richards solution?

  • Lee 1130 posts 3088 karma points
    Feb 15, 2010 @ 13:17
    Lee
    0

    Hmmm ok first off I have tried to get the root which I have checked in the DB and seems to be correct as the ID is -1

    Document doc = new Document(-1);

    Now I tried to loop through the children

                if (doc.HasChildren)
                {
                    foreach (Document childDoc in doc.Children)
                    {
                        sb.Append(childDoc.Id + "<br>");
                    }
                }

    But all I get is one Child?  And it also has the ID of -1?  A touch confused at the moment :S 

     

     

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 15, 2010 @ 14:12
    Nik Wahlberg
    1

    Hi Lee,

    you may want to consider tapping into the Umbraco data layer and query the DB directly for your nodes. This would return an IRecordsReader that you could then simply databind to a grid (or repeater or whatever you need). 

    NodeGrid.DataSource = YourMethodThatReturnsRecords(); //IRecordsReader
    NodeGrid.DataBind();

    Hth,
    Nik

  • Lee 1130 posts 3088 karma points
    Feb 15, 2010 @ 14:24
    Lee
    0

    I think you and Dirk are right, after having a good look around it seems that this is going to have to be my option

  • Phil Dye 149 posts 325 karma points
    Nov 07, 2013 @ 15:24
    Phil Dye
    0

    Lee,

    Reviving an old thread, but did this approach work for you? - I need to do the exact same thing (in a backoffice usercontrol).

    Phil

  • Ivan 165 posts 543 karma points
    Dec 12, 2013 @ 05:26
    Ivan
    0

    Has somebody worked that out?

     

    umbraco.uQuery.GetNode(id).Children - the result doesn't contain unpublished nodes

    umbraco.uQuery.GetNodesByType("docTypeName") - the result doesn't contain unpublished nodes

     

    Is there any chance to get ALL the nodes including the unpublished ones?

  • Thomas Beckert 193 posts 469 karma points
    Jan 02, 2014 @ 20:32
    Thomas Beckert
    0

    Yes, you have to use GetDocument.

     

    This should do it, returning ALL nodes, including the unpublished:

    var node = uQuery.GetDocument(id);
    foreach(var item in node.GetChildDocuments()){
    @* do the magic here *@
    }
Please Sign in or register to post replies

Write your reply to:

Draft