Page template API

This section shows the API functionality available for page templates.

Namespace: Litium.Foundation.Modules.CMS.Templates

Every page instance has to have a template. The template contains the information about the real (physical aspx file) template. The page can only have one of the templates that is defined in its page type. Page type has a collection of templates.

Change template of current page

Current page is type of  page type Article and the page type has a template with name Article1
Check if the new template is valid (connected) for the current site before setting it .

Template template = CurrentPage.PageType is RegularPageType ? CurrentPage.PageType.Templates.GetTemplate("Article1") : null;
if (template != null && template.IsValidForWebSite(CurrentState.WebSiteID))
  CurrentPage.SetTemplate(template, CurrentState.Token);

The real template is an aspx-file that contains layout for a web page. Litium follows Asp.NET standard and the only thing that is required to do is to let the template inherit App_Code.Site.CMS.Templates.BaseTemplate.

All templates except the product page templates are found under the folder Site/CMS/Templates. The styles of the templates are either in UI/Css/main.css or in a css file with the name of the page type (UI/Css/PageTypeName.css). Site/CMS/Templates/Images folder contains minature pictures of the templates.

In the reference implementation of Litium a content place holder called Content is used. The information is rendered in this place holder.

A basic page template

This is a basic template showing a string property called "Text1".

<%@ Page Language="C#" Inherits="App_Code.Site.CMS.Templates.BaseTemplate"%>
<asp:Content ContentPlaceHolderID="Content" runat="Server">
  <web:Text runat="server" Name="Text1" />
Is this page helpful?
Thank you for your feedback!