Last active
November 30, 2022 13:05
SF_10.1, SF_10.2, SF_11.0, SF_11.1, SF_11.2, SF_12.0, SF_12.1, SF_12.2, SF_13.0, SF_13.1, SF_13.2, SF_13.3, SF_14.3 - https://docs.sitefinity.com/for-developers-apply-page-templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Telerik.Sitefinity.Modules.Pages; | |
using Telerik.Sitefinity.Pages.Model; | |
using Telerik.Sitefinity.Workflow; | |
namespace SitefinityWebApp | |
{ | |
public class ApplyPageTemplates_SetTemplateToPageNativeAPI | |
{ | |
public void SetTemplateToPage(Guid pageNodeId, Guid templateId) | |
{ | |
PageManager manager = PageManager.GetManager(); | |
var initialPageNode = manager.GetPageNode(pageNodeId); | |
PageData pageData = initialPageNode.GetPageData(); | |
var temp = manager.EditPage(pageData.Id); | |
temp.TemplateId = templateId; | |
manager.PagesLifecycle.CheckIn(temp); | |
manager.SaveChanges(); | |
var bag = new Dictionary<string, string>(); | |
bag.Add("ContentType", typeof(PageNode).FullName); | |
WorkflowManager.MessageWorkflow(pageNodeId, typeof(PageNode), null, "Publish", false, bag); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment