I'm in the process of making some adjustments to the BlogEngine.net 2.5 Blogging system that will accommodate my publishing needs.
The first feature I need is the ability to have a custom master page for the dynamically created pages or new pages I add to the system. Currently the application only allows for one master page across all pages and blog entries.
After digging in the code for a bit, I made the following adjustments;
BlogEngine.Core changes
1. In the source code version of the project track down the BlogEngine.Core Web\controls\BlogBasePage.cs. This is the file all pages inherit from and its also the file that sets the master page of the selected theme.
2. Make a copy of the file. In my case I named it vTechBlogBasePage.cs (we will use that as that going forward in this example)
3. Update the class name:
//public abstract class BlogBasePage : Page
public abstract class vTechBlogBasePage : Page
4. Now we need to modife the line of code to load the alternate master file for our pages.
//this.MasterPageFile = string.Format("{0}themes/{1}/site.master", Utils.ApplicationRelativeWebRoot, BlogSettings.Instance.GetThemeWithAdjustments(null));
this.MasterPageFile = string.Format("{0}themes/{1}/siteb.master", Utils.ApplicationRelativeWebRoot, BlogSettings.Instance.GetThemeWithAdjustments(null));
5. Now build the project creating the BlogEngine.Core.Dll in the BIN folder.
Web Project Changes
6. In the root of the porject we need update the page.aspx.cs file to inherit from our new vTechBasePage. This file is used to render the custom page you create in the admin module.
//public partial class page : BlogBasePage
public partial class page : vTechBlogBasePage
7. We also need to introduce our new master file. For this example simply make a copy of the site.master file in the themes\standard folder.
8. Rename it to siteb.master file, that what we used in step 3
9. Make sure you update the following line in your master.aspx, and master.aspx.cs
Replace
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="siteb.master.cs" Inherits="StandardSite" %>
with
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="siteb.master.cs" Inherits="StandardSiteB" %>
and
replace
public partial class StandardSite : System.Web.UI.MasterPage
with
public partial class StandardSiteB : System.Web.UI.MasterPage
That should do it, you can now create a page through the admin module and it will use the siteb.master temple as the foundation rather than the standard master file.
I would love your feedback and alternate solution to this issue.
Hope this helps;