Different Master or Layouts pages

Topics: Controls, Themes
Nov 10, 2011 at 5:18 PM

How does one implement support for different Master (in ASPX themes) or Layout (in CSHTML themes) pages in BlogEngine 2.5? For instance, I need a special entry page that would include slideshow and some other widgets but different content pages (more types of them) for displaying pages, post lists etc.?

This is easy enough to be done with both WebForms and ASP.NET MVC but I kinda don't know how to do it in BE. For instance, in my proprietary CMS I read all of the _Layout pages and allow the user to choose one of them when he creates new content page. If this is not possible (I haven't seen anything like that in Create New Page, just the Parent page dropdown), is there a way to specify it in the code?

Nov 10, 2011 at 9:02 PM
Edited Nov 10, 2011 at 9:03 PM

If I understand you correctly, You want the default page to have one masterpage, but the posts and pages will be with a different master page?

You could try manually setting the MasterPageFile property in the default.aspx.cs file to your entry masterpage, and allow your theme in the rest.

default.aspx inherits from BlogEngine.Core.Web.Controls.BlogBasePage and sets the MasterPageFile property in the OnPreInit method. Just override OnPreInit in default.aspx.cs and set the MasterPageFile property after base.OnPreInit.



protected override void OnPreInit(EventArgs e)
    this.MasterPageFile = string.Format("{0}themes/{1}/site.master", 
 BlogSettings.Instance.GetThemeWithAdjustments("YourEntryTheme")); }
Nov 10, 2011 at 9:18 PM

this would work but its too cumbersome, because actually i would like the end user to have the ability to choose the master page for the content page that he is currently creating

Nov 27, 2011 at 12:29 AM

Did you find a solution? I tried the above but it will not work for my needs either.

Nov 27, 2011 at 1:43 AM


[Allow the user to choose one of them when he creates new content page.]

You want your (User) aka "Editors" the ones that are making [posts/pages] on your website to choose the masterpage for that specific [post or page] that they are creating?

Not "Users" the visitors visiting your website.

So have each [Post/Page] connected to a masterpage instead of all of the content connected to just one.

Is that correct?

This will require some custom coding but possible.

1. Add a field to the admin   page/post  for the masterpage

2. Then in BE Core have to change the [Page/Post] to enable that field into each [Page/Post]

3. Then have the Code behind file of the site.master.cs select the master page from the current page [masterpage] field.

In theory that should work.


markoh:  Do you have a live example of a website thats is currently doing this?  Just want to see how it looks.

Also why have so many different masterpages?

Just wanted to know to help out better and to understand what you wanted to do.

What does each masterpage have that different? 

If its just the sidebars that can be done another way instead of masterpages.


Have a Great Day!

Brian Davis