Find the most recently changed page

In my current project I need to know when the latest change was made on any page on the entire site. My first thought was to use FindPagesWithCriteria or maybe to do a recursive GetChildren to find the latest value of the PageData.Changed property. But since EPiServer CMS 6, there is a change log you can ask for this kind of stuff. There is even a public class, used by the Recently Changed Pages gadget you can use, RecentlyChangedPagesFinder.

public DateTime LastModified
{
    get
    {
        RecentlyChangePage lastChangedPage =
            new RecentlyChangedPageFinder().Find(1).FirstOrDefault();

        if (lastChangedPage != null)
            return lastChangedPage.Changed;

        return DateTime.MinValue;
    }
}

This post was first published on EPiServer World, available here.

blog comments powered by Disqus