privatevoid CreateLayout() { // Create new layout object LayoutInfo newLayout = newLayoutInfo(); // Set the properties newLayout.LayoutDisplayName = "My new layout"; newLayout.LayoutCodeName = "MyNewLayout"; newLayout.LayoutDescription = "This is layout created by API Example";
// Save the layout LayoutInfoProvider.SetLayoutInfo(newLayout); }
The following example gets and updates a page layout.
privatebool GetAndUpdateLayout() { // Get the layout LayoutInfo updateLayout = LayoutInfoProvider.GetLayoutInfo("MyNewLayout"); if (updateLayout != null) { // Update the properties updateLayout.LayoutDisplayName = updateLayout.LayoutDisplayName.ToLower(); // Save the changes LayoutInfoProvider.SetLayoutInfo(updateLayout); returntrue; } returnfalse; }
The following example gets and bulk updates page layouts.
privatebool GetAndBulkUpdateLayouts() { // Prepare the parameters string where = "LayoutCodeName LIKE N'MyNewLayout%'"; // Get the data DataSet layouts = LayoutInfoProvider.GetLayouts(where, null); if (!DataHelper.DataSourceIsEmpty(layouts)) { // Loop through the individual items foreach (DataRow layoutDr in layouts.Tables[0].Rows) { // Create object from DataRow LayoutInfo modifyLayout = newLayoutInfo(layoutDr);
// Update the properties modifyLayout.LayoutDisplayName = modifyLayout.LayoutDisplayName.ToUpper();
// Save the changes LayoutInfoProvider.SetLayoutInfo(modifyLayout); } returntrue; } returnfalse; }
The following example deletes a page layout.
privatebool DeleteLayout() { // Get the layout LayoutInfo deleteLayout = LayoutInfoProvider.GetLayoutInfo("MyNewLayout"); // Delete the layout LayoutInfoProvider.DeleteLayoutInfo(deleteLayout); return (deleteLayout != null); }