Sort the BlogEngine Page-List Widget [2.8]





This one is for the sorting of Pages in the BlogEngine 2.8 Page-List widget. By default, the sorting of the pages in the list was in the alphabetic order. However, I wanted to sort the page list in custom way. Unfortunately, there is no control/option for sorting the page-list widget.


To sort the page list in custom order you’ll have to write a bit of code.

Open App_Code/Controls/PageList.cs file.
Look for the BindPages() method in it.
Replace the existing code with the following:-

List<BlogEngine.Core.Page> pagesList = new List<BlogEngine.Core.Page>();
var varPagesList = BlogEngine.Core.Page.Pages.OrderBy(p => p.DateCreated);
pagesList = varPagesList.ToList<BlogEngine.Core.Page>();

var ul = new HtmlGenericControl("ul") { ID = "pagelist" };
ul.Attributes.Add("class", "pagelist");

foreach (var page in pagesList.Where(page => page.ShowInList && page.IsVisibleToPublic))
	var li = new HtmlGenericControl("li");
	var href = page.RelativeLink;
	if (BlogSettings.Instance.RemoveExtensionsFromUrls && !string.IsNullOrEmpty(BlogConfig.FileExtension))
	  href = href.Replace(BlogConfig.FileExtension, "");

	var anc = new HtmlAnchor { HRef = href, InnerHtml = page.Title, Title = page.Description };


return ul;

Now the Page inside that widget will be listed according to their created date field. We can easily modify this field to put a page at the top or at the bottom of the list. To do that, you have to open  App_Data/pages xml-files . These xml files are the description of your pages in the blog. If you open it you will get the created date property there which you can easily modify. A snapshot of one of my page is give below for better understanding.

Thanks …

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.