The following sample code shows how you can create a new pre-defined page layout:
[C#]
using CMS.SiteProvider;
...
// Create new layout object LayoutInfo li = new LayoutInfo();
// Set properties li.LayoutDisplayName = "Test layout"; li.LayoutCodeName = "TestLayout"; li.LayoutDescription = "This is a layout created for an API Example"; li.LayoutCode = "<cc1:CMSWebPartZone ID=\"zoneLeft\" runat=\"server\" />";
// Save to database LayoutInfoProvider.SetLayoutInfo(li); |
The following sample code shows how you can modify an existing pre-defined page layout:
[C#]
using CMS.SiteProvider;
...
// Get layout object by layout code name LayoutInfo li = LayoutInfoProvider.GetLayoutInfo("TestLayout");
// If layout exists if (li != null) { // Update properties li.LayoutDisplayName += " updated"; li.LayoutCode += " updated";
// Save to database LayoutInfoProvider.SetLayoutInfo(li); } |
The following sample code shows how you can delete a pre-defined page layout from the system:
[C#]
using CMS.SiteProvider;
...
// Get layout object by layout code name LayoutInfo li = LayoutInfoProvider.GetLayoutInfo("TestLayout");
// If layout exists if (li != null) { // Delete from database LayoutInfoProvider.DeleteLayoutInfo(li); } |
Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_portal_engine_managing_page_layouts.htm