Display list of most recently changed pages

Vote:
 

Is there a way to display a list of links to the most recently updated pages (up to 10) on Epi 7.0? 

#121015
Apr 29, 2015 20:17
Vote:
 

There's a built-in gadget for that (see this topic). If you'd rather do it through code, I believe you should check ChangeLog.GetChanges.

#121028
Edited, Apr 30, 2015 0:43
Vote:
 

Thanks for a quick reply Johan. I am very new to this so I think I need more direction. Also I'll clarify - I want to display the list of pages (linked) on the user facing website. So when a user goes to our home page, it shows a list of links to the most recently changed pages. Can you elaborate on how I would go about that?

#121072
Apr 30, 2015 14:48
Vote:
 

If you are using ASP.NET MVC you could try something like this. I wrote the code here so it's not tested but I think it should work just fine.

public ActionResult Index(PageData currentPage) {
  var queryService =  ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>();
  var changedPages = GetRecentlyChangedPages(queryService, 10);
  // do something with the result
}
public IEnumerable<PageData> GetRecentlyChangedPages(IPageCriteriaQueryService queryService, int daysBack) {
  var criteriaCollection = new PropertyCriteriaCollection();
  var criteria = new PropertyCriteria {
    Condition = CompareCondition.GreaterThan,
    Name = "PageChanged",
    Type = PropertyDataType.Date,
    Value = DateTime.Now.AddDays(-daysBack).ToString(),
    Required = true
  };

  criteriaCollection.Add(criteria);

  return queryService.FindPagesWithCriteria(ContentReference.StartPage, criteriaCollection);
}

Cheers

- Marcus

#121079
Edited, Apr 30, 2015 16:22
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.