/// <summary> /// Adds page template to site. Called when the "Add template to site" button is pressed. /// Expects the CreatePageTemplate method to be run first. /// </summary> private bool AddPageTemplateToSite() { // Get the page template PageTemplateInfo template = PageTemplateInfoProvider.GetPageTemplateInfo("MyNewTemplate"); if (template != null) { int templateId = template.PageTemplateId; int siteId = CMSContext.CurrentSiteID; // Save the binding PageTemplateSiteInfoProvider.AddPageTemplateToSite(templateId, siteId); return(true); } return(false); }
/// <summary> /// Removes page template from site. Called when the "Remove template from site" button is pressed. /// Expects the AddPageTemplateToSite method to be run first. /// </summary> private bool RemovePageTemplateFromSite() { // Get the page template PageTemplateInfo removeTemplate = PageTemplateInfoProvider.GetPageTemplateInfo("MyNewTemplate"); if (removeTemplate != null) { int siteId = CMSContext.CurrentSiteID; // Get the binding PageTemplateSiteInfo templateSite = PageTemplateSiteInfoProvider.GetPageTemplateSiteInfo(removeTemplate.PageTemplateId, siteId); // Delete the binding PageTemplateSiteInfoProvider.DeletePageTemplateSiteInfo(templateSite); return(true); } return(false); }