This project is read-only.

Startpage template problem

Topics: Developer Forum
May 29, 2008 at 6:29 PM
Edited May 29, 2008 at 6:31 PM

I have created my own content templates and setup a new N2 installation without any problems.
But I noticed a problem with my custom startpage.
When the startpage is registered in web.config (startPageID), I cannot get the page to render fields e.g. Title.
If I create a new startpage and set <startPageID> in web.config to the new item, the first created page renders perfectly.

Has anyone had the same problem?

Here are some code snippets.

Web.config
<components>
    <component id="n2.defaultSite">
        <parameters>
            <rootItemID>1</rootItemID>
            <startPageID>2</startPageID>
        </parameters>
    </component>
</components>

Frontpage.cs
[N2.Definition("FrontPage", "FrontPage", Installer = N2.Installation.InstallerHint.PreferredStartPage)]
[N2.Web.UI.TabPanel("Content", "Content", 0)]
[N2.Details.WithEditableTitle("Title", 10, Focus = true, ContainerName = "Content")]
public class Frontpage : N2.ContentItem
{
    public override string TemplateUrl
    {
        get
        {
            return string.Concat("~/Web/Templates/", this.GetType().Name, "/Default.aspx");
        }
    }
}

Default.aspx
<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder" runat="server">

    <n2:Display ID="TitleDisplay" PropertyName="Title" runat="server" />

</asp:Content>

Default.aspx.cs
public partial class Default : N2.Web.UI.Page<Hojgaard.Templates.Items.Frontpage>
{
    protected void Page_Load(object sender, System.EventArgs e)
    {
    }
}

May 30, 2008 at 10:06 PM
Is it possible that /default.aspx handles the request instaed of  /web/templates/frontpage/default.aspx? N2 doesn't rewrite when a file exists at the requested url.