Copied to clipboard

Flag this post as spam?

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


  • Bex 444 posts 555 karma points
    Aug 04, 2011 @ 13:48
    Bex
    0

    publishing nodes in code doesn't seem to update the cache properly

    Hi!

    I have a website with a number of nodes that have child nodes. The main node has a property called "version" and depending on which of the child nodes are published this version number needs to be updated. 
    This version is then included in some xml that is created via xslt.

    I am using events to do this as follows..

    Document.BeforePublish += new Document.PublishEventHandler(Document_BeforePublish);
      void Document_BeforePublish(Document sender, PublishEventArgs e)
            {
                switch (sender.ContentType.Alias)
                {
      case "NodeImLookingFor":
    //load the document with version property
                Document doc= new Document(sender.parentId); //the document needed is usually the parent, this has just been condensed down for demonstration purposes
                //grab the current version number           
    int newVersionNumber = Convert.ToInt32(trail.getProperty("version").Value) + 1;
                //update the version nyumber
                doc.getProperty("version").Value = newVersionNumber;
             
                    doc.Publish(User.GetUser(0));           
                    library.UpdateDocumentCache(sender.parentId);
                    library.RefreshContent();
                   
                }
    break:
    }

    If I then look in the backend to the property it has been updated, but if I use this property in my xslt it doesn't see it as being updated.
    The only way to get it to update is to publish the parent node directly!
    I have got caching turned off on the macro and can't think of what else I need to do?
    What am I doing wrong?
    Bex

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Aug 05, 2011 @ 08:17
    Bo Damgaard Mortensen
    0

    Hi Bex,

    Just our of curiosity, have you tried to call the document.Save() method before calling the publish() method? :)

Please Sign in or register to post replies

Write your reply to:

Draft