November Happy Hour will be moved to Thursday December 5th.

Get data from previously published page

Vote:
 

I am trying to get the Changed PageData property value from the first published version of a page to compare it with the latest published version.

The purpose of this is to write out "Last changed " on an article.

How can I do it?

I have tried to use

ServiceLocator.Current.GetInstance().List(Model.PageLink, Model.LanguageBranch)

but I can't get any PageData with it...

#121854
May 19, 2015 8:37
Vote:
 

Maybe I get you wrong, but @Model.StartPublish (or @Model.Changed) will give you the "last changed" date. No need to dive into versions.

However is you want to create a list of change dates you can use this code:

var cvr = ServiceLocator.Current.GetInstance<IContentVersionRepository>();
var publicationDates = cvr.List(currentPage.ContentLink, currentPage.Language.Name)
                                    .Where(s => s.Status == VersionStatus.PreviouslyPublished).Select(p => p.Saved);
#121960
May 21, 2015 23:33
Vote:
 

Thanks!

I use this for finding out if the Changed date has been updated:

DataFactory.Instance.ListVersions(page.PageLink, page.LanguageBranch)
    .Where(version => version.Status == VersionStatus.PreviouslyPublished)
    .Any(version => version.Saved < Changed);

and then I print out the value of Changed if the code above returns true.

#122272
May 29, 2015 9:03
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.