BlogEngine.Net Pages And PageSiteMap Tweak

Topics: Business Logic Layer
Apr 12, 2011 at 10:09 PM

Hi All,

While working on one project - blogengine as CMS, I came across with one minor issue when PageSiteMap was returning null for some pages. I investigated it and found that at one place PageSiteMap is comparing page URL with its title which is not a global case. As in many case we used to change page slug which in turn becomes Page URL.

So if anyone who is facing this issue or changing Page slug change the following code to make it correct.

File: BlogEngine.Core\Web\Controls\PageSiteMap.cs

Old Code:

return Page.Pages
.Where(page => page.IsVisible && url.Equals(Utils.RemoveIllegalCharacters(page.Title), StringComparison.OrdinalIgnoreCase))
.Select(page => new SiteMapNode(this, page.Id.ToString(), page.RelativeLink, page.Title, page.Description)).FirstOrDefault();

New Code:

return Page.Pages
.Where(page => page.IsVisible && url.Equals(Utils.RemoveIllegalCharacters(page.Slug), StringComparison.OrdinalIgnoreCase))
.Select(page => new SiteMapNode(this, page.Id.ToString(), page.RelativeLink, page.Title, page.Description)).FirstOrDefault();

I hope this will help some of you.

Thanks,

BlogEngineWall