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.)
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.
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.)
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:
Note that this hits the database, so isn't something you want to be doing on every page load.
@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!
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.)
@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
is working on a reply...