Page type API

This section shows how to programmatically create page types and how to use the Litium API.

Namespace: Litium.Foundation.Modules.CMS.PageTypes

Every page instance is connected to a page type. The page type itself contains settings, templates and property information that each page will use.

PageType is an abstract class. ProductCatalogPageType and RegularPageType inherit from this parent class. Pages of ProductCatalogPageType are used to publish products and product groups from the Product Catalog Module in the public web site. All other pages have a RegularPageType.

ProductCatalogPageType has no Templates collection since the templates that will be used to show products and product groups are determined in the field templates of these product and categories.

Get a page type object and check if it is valid (connected) on a website

var website = ModuleCMS.Instance.WebSites.GetWebSite("mywebsite.com");
var pageType = ModuleCMS.Instance.PageTypes.GetPageType("Article");
if (pageType != null && pageType.IsValidForWebSite(website.ID) )
{
  // do something
}

Get a page type object and check if it is a RegularPageType

var pageType = ModuleCMS.Instance.PageTypes.GetPageType("Article");
if (pageType != null && pageType is RegularPageType)
{
  // do something
}

Create a property of a page type

var pageType = ModuleCMS.Instance.PageTypes.GetPageType("Article");
if (pageType != null)
{
  // Try to get the property and if it does not exist then create it.
  var myProperty = pageType.Content.GetProperty("PropertyName") as StringShortProperty ?? 
                   pageType.Content.CreateStringShortProperty("PropertyName", false, false, false, ModuleCMS.Instance.AdminToken);
}

The PageType property of a Page object also returns a PageType object

if (CurrentPage.PageType is RegularPageType)
{
   // do something
}

 

Is this page helpful?
Thank you for your feedback!