Copied to clipboard

Flag this post as spam?

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


  • Umbraco 137 posts 294 karma points
    Oct 16, 2011 @ 20:52
    Umbraco
    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 11280 posts 23678 karma points MVP 11x 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.

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

    I will try that, thanks!

Please Sign in or register to post replies

Write your reply to:

Draft