possible bug on recycle bin
Hi,
I am not sure if this is a normal behavior or not.
Basically I am retrieving a list of top level pages via code using something like:
var topLevelPages = manager
.GetPageNodes()
.Where(p => p.Parent.Title == "Pages")
.OrderBy(o => o.Ordinal);
The problem in not in the code but on the recycle bin.
I had a list of pages on the CMS market "show in the menu". The snippet above (with an if statement) is picking everything fine.
I deleted a top level page (was a group page) and I could still see the page listed. (The code was still picking the page even though I delete it).
In order to completely remove the page from being displayed I had to remove it from the bin.
I suppose the code should not picks up things from the bin?
Hope this makes sense
Thanks
Francesco
Hello Francesco,
Since the release of "Recycle bin" feature, if you wish to filter out pages located in your bin, you have to add
pN.Page.Visible == true as a parameter:
var pageNodes = App.WorkWith()
.Pages()
.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Where(pN => (pN.Page !=
null
&& pN.Page.Status == ContentLifecycleStatus.Live && pN.Page.Visible ==
true
))
.Get()
.ToList();
Can you please explain the difference between
pN.Page.Status == ContentLifecycleStatus.Live
pN.Page.Visible ==
true
My understanding is that if something is "ContentLifecycleStatus.Live" then it can't be in the Recycle Bin. Am I incorrect in my understanding of the Recycle Bin?
I've experienced similar issues when querying images, previous widgets I've created used:
HomepageSliderRepeater.DataSource = album.Images().Where(i => ContentLifecycleStatus.Live).OrderBy(i => i.Ordinal);
Which then had to be changed to:
HomepageSliderRepeater.DataSource = album.Images().Where(i => i.Status == ContentLifecycleStatus.Live).OrderBy(i => i.Ordinal);
Is this adjustment required for all widgets which query content types that can be placed in the Recycle Bin?
Hi Jeff,
If you would like to get the live versions of the pages or content items which are visible on the frontend (excluding the pages or content items from the recycle bin) you should also check the IsDeleted property of the pages or items:
PageManager pageManager = PageManager.GetManager();
IQueryable<PageData> pages = pageManager.GetPageDataList().Where(pData => pData.IsDeleted ==
false
&& pData.Status == ContentLifecycleStatus.Live);