How do I get the 10 newest and 10 oldest pages?
I am trying to create an admin widget that shows me the 10 oldest pages (longest time since last edit) and the 10 newest pages. (most recent edits)
Here is the code I have below. For some reason both are returning the SAME result set. Any idea why?
// Get the 10 newest pages
IQueryable<PageNode> NewPages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(p => p.ApprovalWorkflowState ==
"Published"
).OrderByDescending(p => p.LastModified.Date).Take(10).Get();
// ...and the 10 oldest pages
IQueryable<PageNode> OldPages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(p => p.ApprovalWorkflowState ==
"Published"
).OrderBy(p => p.LastModified.Date).Take(10).Get();
.ThatArePublished()
// instead of:
.Where(p => p.ApprovalWorkflowState ==
"Published"
)
(I'm showing my rust with this... ;-)
This will get the last 10 pages edited:
PageManager pageManager = PageManager.GetManager();
IQueryable<PageNode> pages = pageManager.GetPageNodes().OrderByDescending(n => n.LastModified).Take(10);
IQueryable<PageNode> pages = pageManager.GetPageNodes().Where(n => n.ApprovalWorkflowState ==
"Published"
).OrderByDescending(n => n.LastModified).Take(NumberToDisplay);