Copied to clipboard

Flag this post as spam?

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


  • Rune Grønkjær 1303 posts 2895 karma points
    May 09, 2011 @ 11:48
    Rune Grønkjær
    0

    XML cache has not been updated on Document.AfterPublish

    Hi guys,

    I'm wrestling the Umbraco event API and I'm stuck. I need to traverse the document xml when a node is published. I am using content.Instance.XmlContent, and try to get the resently published document like this:

    void Document_AfterPublish( Document sender, umbraco.cms.businesslogic.PublishEventArgs e ) {
      XPathNavigator xmlNode = content.Instance.XmlContent.CreateNavigator();
      if ( xmlNode.MoveToId( sender.Id.ToString() ) ) {
        //Do traversing
      }
    }

    This works great on nodes that have allready been published. New nodes on the other hand does not exist in the XmlContent yet, allthough the event is called AFTER publish.

    I need to use xpath to find what I need in the XmlDocument, after finding the resently published node.

    Any ideas on how to do this on both new and old nodes?

    /Rune

  • Niels Hartvig 1951 posts 2391 karma points admin hq c-trib
    May 09, 2011 @ 11:53
    Niels Hartvig
    2

    It's because at that point the document is only *prepared* for publishing. It's when you call umbraco.library.UpdateDocumentCache() that the XML is being populated. So you probably want to listen to the umbraco.content.BeforeUpdateDocumentCache event...

  • Rune Grønkjær 1303 posts 2895 karma points
    May 09, 2011 @ 11:56
    Rune Grønkjær
    0

    Thx.

    Will try that.

    /Rune

  • Rune Grønkjær 1303 posts 2895 karma points
    May 09, 2011 @ 13:10
    Rune Grønkjær
    0

    Works like a charm. Thanks again Niels.

    /Rune

  • 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