Creating a custom start page

Topics: Developer Forum
Apr 16, 2009 at 10:29 PM
I've created my own pages with a custom master page template. It works just fine for every page type except the start page. The start page just won't use my master page template. It always uses the default master page.

I suspected that one of the problems was that the start page / root page of the site was the of the wrong discrimiator, so I tried to change that in the database, but that didn't work either.

So I have two questions:

1. What is the best way to create your own start pages and master pages?
2. What is the best way to change the type of an already existing page?

Thanks!

// Johan
Coordinator
Apr 17, 2009 at 12:07 AM
Could it be that you're actually accessing the old start page? Could you delete it and create your own instead from the install page? Another way is to hack the database.
May 27, 2009 at 1:00 PM

I have the same problem. The start page is definitely my new type, I added a message that I print out from the start page template/view-aspx which appears when I browse to the site.

Don't know if I'm doing anything wrong here.

Simplified code:

[Definition("My own startpage")]
[Template("~/UI/Views/StartPage.aspx")]
public class SEStartPage : N2.Templates.Items.StartPage {
    public override string TemplateUrl {
        get { return "~/UI/Views/StartPage.aspx"; }
    }
}

and the aspx:

<%@ Page MasterPageFile="~/UI/Layouts/Top+SubMenu.master" Language="C#" CodeBehind="StartPage.aspx.cs" Inherits="MyNameSpace.UI.StartPage" %>
<asp:Content ContentPlaceHolderID="Content" runat="server">
    Hello from StartPage.aspx!
</asp:Content>

Where ~/UI/Layouts/Top+SubMenu.master is the path to my copied and then modified Master page.

 

I have double checked in the database, and the type of all the existing pages (I have two language roots only in this DB so far) is SEStartPage.

 

/Tomas

Coordinator
May 27, 2009 at 6:00 PM

The problem = that your master page is overwritten?

In that case, what does MyNameSpace.UI.StartPage inherit from? If you want the master page to be set to the one configured you should use TemplatePage<>, to keep the one declared in the aspx you should not inherit from TemplatePage<>.

To configure another master page for all views you configure <n2><templates masterPageFile="~/yes.master"

May 27, 2009 at 6:45 PM

Thank you for your answer. I found out about the <templates /> configuration tag just before I received your answer, but now I'm wondering if I can inherit from something else than TemplatePage (higher up the inheritance chain I presume) and still use an Item that inherits from Templates.StartPage?

The <templates /> tag solves my problem, but I wouldn't mind a bit more flexibility if possible without losing too much functionality.

/Tomas

Coordinator
May 27, 2009 at 7:57 PM

Sure, you can use N2.Web.UI.ContentPage<> or System.Web.UI.Page

May 27, 2009 at 9:14 PM

Alright, thanks. I'll try N2.Web.UI.ContentPage then.