Creating Different Side Panels on CMS Pages

Topics: ASP.NET 2.0, Business Logic Layer, Controls, Themes
Sep 24, 2012 at 12:58 PM

I need to have different side panels on the CMS pages which will contain customer testimonials. If I place it on the master page, it will be the same for each page...

I don't want to hard-code a page ID switch statement in the site master code-behind. Is there a more direct way of doing this?

Thanks in advance :-)


Sep 24, 2012 at 1:19 PM

Hi Anthony,

The page itself has very few properties you can play with. If you don't use the ID (which I agree that it's not very pretty to hard-code), what are you going to use? Perhaps the page's title? Or use a magic keyword? Still it's a bit ugly. So I would say if the ID works, use it.

If you want to go for the title for instance, you're going to have to do something like this in your theme's masterpage:

var id = Guid.Parse(Request.QueryString["id"]);
var page = BlogEngine.Core.Page.GetPage(id);
mySpecialPanel.Visible = page.Title == "My Page";

I'm writing the code off the top of my head and if I remember correctly you're going to have to load the page again because it's not accessible from the master page (that's not expensive though thanks to caching).




Sep 24, 2012 at 1:22 PM
Edited Sep 24, 2012 at 1:57 PM

Hi Nikolaos,

I got the following error:

Error  12  The best overloaded method match for 'BlogEngine.Core.Page.GetPage(System.Guid)' has some invalid arguments   

This fixed it:   

// Use page id to toggle correct side panel
System.Guid id = Guid.Parse(Request.QueryString["id"]);
BlogEngine.Core.Page page = BlogEngine.Core.Page.GetPage(id); 

Thanks for your help :-)