Copied to clipboard

Flag this post as spam?

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


  • James Borza 34 posts 95 karma points
    Mar 27, 2012 @ 01:54
    James Borza
    0

    umbraco.NodeFactory.Node.Children returning unpublished nodes 4.7.1.1

    Hi I'm running 4.7.1.1.

    I unpublished a number of documents using umbraco.cms.businesslogic.web.Document:

    doc.UnPublish();
    doc.Save();
    umbraco.library.UpdateDocumentCache(doc.Id);

     

    Now the following code is returning unpublished nodes (from above):

    Node parent = new Node(1234);
    
    foreach (Node y in parent.Children)
    {
      foreach (Node n in y.Children)
      {
              //do something
      }
    }

     

    I think the issue is my xml cache, is there a way to force the xml to rebuild?

    Thanks in advance.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 27, 2012 @ 05:16
    Tom Fulton
    0

    Hi James,

    In addition to the document.UnPublish, try umbraco.library.UnPublishSingleNode(documentId).  I think that's all you need, but if that's not enough try also umbraco.library.RefreshContent()

    Check this wiki for more info:  Unpublish a document

    -Tom

  • James Borza 34 posts 95 karma points
    Mar 27, 2012 @ 18:43
    James Borza
    0

    Hi Tom, thanks for the reply, that fixed it!

    The umbraco.library.RefreshContent() didn't resolve the issue but looping through the nodes that shouldn't be published and applying document.UnPublish(id) then umbraco.library.RefreshContent() fixed the issue.

    For anyone who runs into this:

    Node node = new Node(1234);
    
    foreach (Node letter in node.Children)
    {
        foreach (Node n in letter.Children)
        {
            if (n.GetProperty("file").Value == "") //testing, if met these nodes shouldn't be published
            {
                umbraco.library.UnPublishSingleNode(n.Id);
            }
        }
    }
    
    umbraco.library.RefreshContent();
Please Sign in or register to post replies

Write your reply to:

Draft