Bare-Bones Master Page Template

Turn Master Page files into a C1 CMS Page template

For a Master Page (.master and .master.cs files) to serve a standard C1 CMS Page template, it should meet the minimum requirements to where it should be located and what is should include:

  1. The Master Page files should be put in ~/App_Data/PageTemplates.
  2. The Web Form class in use must inherit from the MasterPagePageTemplate class.
  3. At least the TemplateId (GUID) property must be implemented to set the template's unique ID.
  4. [not required] It is a good practice to also implement the TemplateTitle (string) property that sets the template's title visible in the CMS Console. Otherwise, the filename will be used instead.
  5. At least one XhtmlDocument property must be declared with a Placeholder attribute. (It will serve as a standard C1 CMS content placeholder.)
  6. In the web form (.master) the <c1:Render/> element should be used to render the content of the declared placeholder (from Step 4).
  7. [not required] It is also a good practice to use the <c1:Title/> element to set the page title <title></title> via the template.

.master

<%@ Master Language="C#" AutoEventWireup="true" 
	CodeFile="BareBonesMasterPageTemplate.master.cs" Inherits="MyPageTemplate" %>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title><c1:Title runat="server"/></title>
    </head>
    <body>
	    <c1:Render Markup="<%# Content %>" runat="server" />
    </body>
</html>
 

.master.cs

using System;
using Composite.Core.Xml;
using Composite.Core.PageTemplates;
using Composite.Plugins.PageTemplates.MasterPages;

public partial class MyPageTemplate : MasterPagePageTemplate
{
    public override Guid TemplateId
    {
        get { return new Guid("25de2e26-ab15-4490-8501-b3e8dcb90822"); }
    }

    [Placeholder(Id = "content", Title = "Main Content", IsDefault = true)]
    public XhtmlDocument Content { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

The above sample code/markup is enough to get a Master Page based template in C1 CMS.