AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. Development
  3. Page layouts

Page layouts


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Setting a custom layout for a page template
  • Creating a shared page layout
  • Updating a shared page layout
  • Updating multiple shared page layouts
  • Assigning a shared page layout to a page template
  • Deleting a shared page layout

Setting a custom layout for a page template

C#
// Gets the page template
PageTemplateInfo pageTemplate = PageTemplateInfoProvider.GetPageTemplateInfo("NewTemplate");
if (pageTemplate != null)
{
    // Sets the template's layout type to ASCX
    pageTemplate.PageTemplateLayoutType = LayoutTypeEnum.Ascx;

    // Sets the custom layout code of the template
    pageTemplate.PageTemplateLayout = "<cms:CMSWebPartZone ZoneID=\"zoneExample\" runat=\"server\" />";

    // Saves the template changes to the database
    PageTemplateInfoProvider.SetPageTemplateInfo(pageTemplate);
}
> Back to list of examples

Creating a shared page layout

C#
// Creates a new layout object
LayoutInfo newLayout = new LayoutInfo();

// Sets the layout properties
newLayout.LayoutDisplayName = "New layout";
newLayout.LayoutCodeName = "NewLayout";
newLayout.LayoutDescription = "This is a layout created by an API example";
newLayout.LayoutType = LayoutTypeEnum.Ascx;
newLayout.LayoutCode = "<cms:CMSWebPartZone ZoneID=\"zoneA\" runat=\"server\" />";

// Saves the layout to the database
LayoutInfoProvider.SetLayoutInfo(newLayout);
> Back to list of examples

Updating a shared page layout

C#
// Gets the layout
LayoutInfo updateLayout = LayoutInfoProvider.GetLayoutInfo("NewLayout");
if (updateLayout != null)
{
    // Adds another web part zone into the layout code
    updateLayout.LayoutCode += "<cms:CMSWebPartZone ZoneID=\"zoneB\" runat=\"server\" />";

    // Saves the changes to the database
    LayoutInfoProvider.SetLayoutInfo(updateLayout);
}
> Back to list of examples

Updating multiple shared page layouts

C#
// Gets all shared page layouts whose code name starts with 'NewLayout'
var layouts = LayoutInfoProvider.GetLayouts().WhereStartsWith("LayoutCodeName", "NewLayout");

// Loops through individual layouts
foreach (LayoutInfo layout in layouts)
{               
    // Updates the layout properties
    layout.LayoutDisplayName = layout.LayoutDisplayName.ToUpper();

    // Saves the changes to the database
    LayoutInfoProvider.SetLayoutInfo(layout);
}
> Back to list of examples

Assigning a shared page layout to a page template

C#
// Gets the page template
PageTemplateInfo pageTemplate = PageTemplateInfoProvider.GetPageTemplateInfo("NewTemplate");

// Gets the layout
LayoutInfo sharedLayout = LayoutInfoProvider.GetLayoutInfo("NewLayout");

if ((pageTemplate != null) && (sharedLayout != null))
{
    // Assigns the page layout to the template
    pageTemplate.LayoutID = sharedLayout.LayoutId;              

    // Saves the template changes to the database
    PageTemplateInfoProvider.SetPageTemplateInfo(pageTemplate);
}
> Back to list of examples

Deleting a shared page layout

C#
// Gets the layout
LayoutInfo deleteLayout = LayoutInfoProvider.GetLayoutInfo("NewLayout");

if (deleteLayout != null)
{
    // Deletes the layout
    LayoutInfoProvider.DeleteLayoutInfo(deleteLayout);
}
> Back to list of examples