Getting the Last Modified List

Posted by Community Admin on 04-Aug-2018 03:29

Getting the Last Modified List

All Replies

Posted by Community Admin on 01-Jun-2011 00:00

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();

It seems to be returning like a random 5 items somewhere in the middle of the dataset instead of the last 5 modified pages

What am I doing wrong with it...?

Posted by Community Admin on 01-Jun-2011 00:00

Also...is there no way to get the URL with the Pages Fluent (like with that manager)?

Posted by Community Admin on 01-Jun-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 01-Jun-2011 00:00

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?

Posted by Community Admin on 02-Jun-2011 00:00

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();


Greetings,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 02-Jun-2011 00:00

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?

Posted by Community Admin on 03-Jun-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 03-Jun-2011 00:00

Epic fail :)

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

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();

Source File: C:\My Dropbox\Projects\Leap\OCFP\Web\UserControls\RecentUpdates\RecentUpdates.ascx.cs    Line: 25

Stack Trace:

[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

Posted by Community Admin on 08-Jun-2011 00:00

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();


Kind regards,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed