Copied to clipboard

Flag this post as spam?

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


  • Eric Schrepel 161 posts 226 karma points
    Aug 10, 2016 @ 20:56
    Eric Schrepel
    0

    Razor code to list a node's rollback/version dates?

    In Umbraco 7.4.3, trying to list all rollback dates for a subset of nodes on our site. Can't tell if that's possible.

    (Reason: we have a few nodes for which we were relying on the UpdateDate property to show when a node was last human-edited. But today we ran a Content.SaveAndPublish on a bunch of those nodes [for an unrelated reason], which then set the UpdateDate to today for all of them, oops.)

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Aug 10, 2016 @ 21:24
    Dan Diplo
    0

    You can use the ContentService to do this. It has a method called GetVersions(int id) which will return a collection of all the versions of a particular node.

    So, to get a list of all UpdateDates for a node you could do:

    var previousDates = UmbracoContext.Application.Services.ContentService.GetVersions(1234).Select(x => x.UpdateDate);
    

    Note that this hits the database, so isn't something you want to be doing on every page load.

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Aug 10, 2016 @ 21:55
    Jon R. Humphrey
    0

    @Dan,

    Thanks for the tip, I was thinking about something like this myself!

    @Eric,

    Sounds like a perfect custom dashboard to me! Yell if you want to discuss?

    Cheers!

  • Eric Schrepel 161 posts 226 karma points
    Aug 10, 2016 @ 22:03
    Eric Schrepel
    0

    I haven't created custom dashboards yet but would be interested in pursuing that soon. (I know I should be doing more of that for our users.)

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Aug 10, 2016 @ 22:05
    Jon R. Humphrey
    0

    @Eric,

    Me neither so no worries, it's always fun to start in the deep end!

    Throw me a ping when you've got time and let's see what we could do!

    J

Please Sign in or register to post replies

Write your reply to:

Draft