Sitefinity CMS

Modifying Templates Send comments on this topic.
See Also
Developing with Sitefinity > Pages > Pages API Walkthrough > Templates > Modifying Templates

Glossary Item Box

Since both templates and pages implement the basic IPage interface, you will notice that modifying pages and templates is almost identical. Both have Staged property of IStagedPage type which represents the staged version of a page or template, through which you can modify the appearance and controls of a page or a template.

Open template for editing and change its default theme:

SaveTemplate(IPageTemplate template) Copy Code
// create a new instance of CmsManager
Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();
// let's find the template with name "Template 1"
Telerik.Cms.IPageTemplate template = cmsManager.GetTemplate("Template 1");
// we need to get template object associated with a transaction in order to modify it
Telerik.Cms.IPageTemplate templateForEditing = cmsManager.GetTemplate(template.ID, true);
// let's change the default theme for the template
// notice how IPageTemplate has Staged property just as ICmsPage objects. This means
// that templates Staged versions can be modified in the same way as staged pages
templateForEditing.Staged.Theme = "White fluid";
// finally we need to save the modified template with CmsManager
cmsManager.SaveTemplate(templateForEditing);

 

See Also