Copied to clipboard

Flag this post as spam?

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


  • Michiel 137 posts 294 karma points
    Oct 16, 2011 @ 20:52
    Michiel
    0

    How can I find the date and time a document was first published?

    Both the CreateDate and UpdateDate properties are not what I need to display, since the first may be some time before official publication, and the second may change (more than once) after official publication when correcting errors in the document.

    I was thinking that I may inspect previous versions of the document for this, but as usual I have difficulty finding API documentation.

    Any tips? 

     

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Oct 16, 2011 @ 21:05
    Jan Skovgaard
    0

    Hi Michiel

    Not sure if you can access the different versions using the API (I'm not saying you can't, just that I'm not sure - not being a backend dev. myself).

    But I'm thinking it perhaps would be easier to create a custom field under "properties" called "publishdate", which you populate with the date using an afterpublish event for instance and make sure that the value is only set the first time a node gets published...

    There is an overview of all events in Umbraco here: http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events

    Hope my explanation makes sense :)

    /Jan

  • Rodion Novoselov 694 posts 859 karma points
    Oct 16, 2011 @ 21:44
    Rodion Novoselov
    0

    Hi. I'm not sure, cause I haven't seen any more or less official doc to it, but it seems that 

    var d = new Document(id).GetVersions().Select(v => v.Date).Skip(1).FirstOrDefault();

    is going to emit what's required.

  • Michiel 137 posts 294 karma points
    Oct 18, 2011 @ 09:52
    Michiel
    0

    I will try that, thanks!

  • 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