Getting the Last Modified List
Here's my query...
var pages = App.WorkWith().Pages()
.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Where(x => x.NodeType == Telerik.Sitefinity.Pages.Model.NodeType.Standard)
.ThatArePublished()
.OrderByDescending(x => x.LastModified)
.Take(
this
.Count)
.Get().ToList();
Also...is there no way to get the URL with the Pages Fluent (like with that manager)?
Hello Steve,
Try adding the ContentLifecycleStatus.Live to your query. The PageNode has a property Urls which you can use to get the page url. Urls returns IList of UrlData where you can call RedirectToDefault (Gets or sets a value indicating whether to redirect this URL to the default URL.)
All the best,
Ivan Dimitrov
the Telerik team
Thanks Ivan...
What about the first post though...
What am I doing wrong in that fluent query where it's not giving me the top X last modified pages?
Hello Steve,
Can you try with the blow code sample and let me know if the problems still persist?
var lastTwo = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Where(pG => pG.Page.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).Get()
.OrderByDescending(pG => pG.Page.LastModified).Take(2)
.ToList();
I'll give it a try...
I was under the assumption that everything before the GET is what OA compiles into it's query, so I was putting that at the end...this looks like it'll get everything from the DB then just order and filter out all but the last couple items?
Hi Steve,
Did you have the time to test the provided sample? Please get back to me if it does not suit the desired functionality, or you have some additional questions.
Regards,
Boyan Barnev
the Telerik team
Epic fail :)
Line 23: public void OnRecentUpdateList_NeedsDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
Line 24: var recentUpdates = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
Line 25: .Where(pG => pG.Page.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).Get()
Line 26: .OrderByDescending(pG => pG.Page.LastModified).Take(this.Count)
Line 27: .ToList();
|
[NullReferenceException: Object reference not set to an instance of an object.] SitefinityWebApp.UserControls.RecentUpdates.RecentUpdates.<OnRecentUpdateList_NeedsDataSource>b__0(PageNode pG) in C:\My Dropbox\Projects\Leap\OCFP\Web\UserControls\RecentUpdates\RecentUpdates.ascx.cs:25 System.Linq.WhereEnumerableIterator`1.MoveNext() +155 System.Linq.Buffer`1..ctor(IEnumerable`1 source) +487 System.Linq.<GetEnumerator>d__0.MoveNext() +145 System.Linq.<TakeIterator>d__3a`1.MoveNext() +375 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +471 System.Linq.Enumerable.ToList(IEnumerable`1 source) +79 SitefinityWebApp.UserControls.RecentUpdates.RecentUpdates.OnRecentUpdateList_NeedsDataSource(Object sender, RadListViewNeedDataSourceEventArgs e) in C:\My Dropbox\Projects\Leap\OCFP\Web\UserControls\RecentUpdates\RecentUpdates.ascx.cs:24 Telerik.Web.UI.RadListView.OnNeedDataSource(RadListViewNeedDataSourceEventArgs e) +197 Telerik.Web.UI.RadListView.AutoDataBind(RadListViewRebindReason rebindReason) +183 System.Web.UI.Control.LoadRecursive() +70 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Control.LoadRecursive() +189 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3047 |
Hello Steve,
Thank you for pointing that out, forgot to include the check for group pages in the sample (since they don't have PageData object). Please find below the revised sample:
var lastTwoPages = App.WorkWith()
.Pages()
.Where(p => p.Page !=
null
&& p.Page.Status == ContentLifecycleStatus.Live)
.Get()
.OrderByDescending(pG => pG.Page.LastModified).Take(2)
.ToList();