Reputation: 319
When i am sorting order of the pages in Episerver, its affecting the website also. means website pages are also changes sorting order.
how we can sort order of pages in episerver in a way that it should not affects website page sorting order.
Is there any configuration or settings in episerver?
Upvotes: 0
Views: 809
Reputation: 26277
Assuming you have a PageDataCollection
you use the FilterSort
class
Example
// your pages
PageDataCollection _newsPageItems;
FilterForVisitor.Filter(_newsPageItems);
new FilterSort(FilterSortOrder.PublishedDescending).Filter(_newsPageItems);
// The _newsPageItems are now filtered and sorted
This is the standard way of sorting and securing listed information from Episerver, also read the article Searching for pages based on page type
Considering you use the DataFactory to fetch a list with pages you can build a PageDataCollection from a Enumerable<PageData>
object instance
Also using the DataFactory
is bad practice and you should be using FilterForVisitor
as well. My recommended implementation would be
// Construct an IContentLoader, this can also be done using Dependency Injection
var loader = ServiceLocator.Current.GetInstance<IContentLoader>();
// Get the children of your reference
var children = loader.GetChildren<PageData>(pageLink, LanguageSelector.AutoDetect(true));
// Construct new PageDataCollection and filter for visitor
var sortableChildren = EPiServer.Filters.FilterForVisitor.Filter(children);
// Sort
FilterSort sortFilter = new FilterSort(FilterSortOrder.CreatedDescending);
sortFilter.Sort(sortableChildren);
Upvotes: 1