Default Master Page Template

Take a closer look at a Master Page template created by default.

When you create a Master Page template in the CMS Console, it will includes some required as well as sample code and markup that you can reuse or replace with your own.

Let's first take a look at a Master Page "code file" (.master.cs).

Inheriting from MasterPagePageTemplate class

All Master Page templates in C1 CMS must inherit from MasterPagePageTemplate.

public partial class page_template : MasterPagePageTemplate

Template ID and title

You should at least specify the template's ID in the TemplateId property. Setting the template's title in the TemplateTitle property is a good practice. If the title is not set, the filename will be used instead in the CMS Console GUI.

 
public partial class page_template : MasterPagePageTemplate
{
	public override Guid TemplateId
	{
		get { return new Guid("aff73082-7474-4b48-aaef-470d61781514"); }
	}

	public override string TemplateTitle 
	{
		get { return "Default Master Page"; }
	}
}


Placeholders

The new Master Page template must also declare at least one content placeholder using an XhtmDocument property and a Placeholder attribute on it.

 
public partial class page_template : MasterPagePageTemplate
{
	[Placeholder(Id="content", Title="Main Content", IsDefault=true)]
	public XhtmlDocument Content { get; set; }
	
	[Placeholder(Id="bottom", Title = "Bottom")]
	public XhtmlDocument Bottom { get; set; }
}

Content placeholders create separate content areas for the page based on this template. This is where a page can be edited in Visual Editor.

By default, two placeholders are declared: "Content" (default) and "Bottom".

Read more on adding content placeholders in Master Page templates.

Markup (.master file)

The sample .master file has some XHTML by default, which makes use of C1 CMS-specific controls (see below).

You are free to change the markup the way you need or totally remove it.

<c1:Title/>, <c1:DescriptionMetaTag/>, <c1:Description/>

  • The <c1:Title/> element inserts the title of the page the template is used for.
  • The <c1:Description/> inserts the page's description.
  • The <c1:DescriptionMetaTag/> inserts <meta name="description" content="..."/> using the page's description.
<head runat="server">
	<title>
		<c1:Title id="title" runat="server"/>
	</title>
	<c1:DescriptionMetaTag runat="server" />
</head>
<body>
		<h1>
			<c1:Title runat="server" />
		</h1> 
		<h2>
			<c1:Description runat="server" />
		</h2>
</body>

Read more on using a page's title and description in Master Page templates.

<c1:Render/>

The <c1:Render/> control renders XHTML from a placeholder. In the sample .master file both "Content" and "Bottom" placeholders are rendered.

<body>
		<div>
			<c1:Render Markup="<%# Content %>" runat="server" />
		</div>
		<h2>Bottom Placeholder</h2>
		<div>
			<c1:Render Markup="<%# Bottom %>" runat="server" />
		</div>
</body>

Read more on adding content placeholders in Master Page templates.

<f:function/>

Using the function markup inserted via the <f:function/> element, two built-in CMS Functions are executed.

Composite.Web.Html.Template.LangAttribute appends a lang='...' attribute the the <html /> element, setting the language of the current page.

<f:function name="Composite.Web.Html.Template.LangAttribute" runat="server" />

Composite.Web.Html.Template.CommonMetaTags adds some common HTML meta tags ("Content-Type", "Designer", "Generator") you may want in your <head/> element.

<f:function name="Composite.Web.Html.Template.CommonMetaTags" runat="server" />

Read more on executing CMS Functions in Master Page templates.

You are free to change the markup the way you need in your Master Page or totally remove it.
Composite.Web.Html.Template.CommonMetaTags ← IEnumerable<XElement>Common HTML meta tags you probably want in yout html head
<f:function name="Composite.Web.Html.Template.LangAttribute" runat="server" />