Last active
December 13, 2018 18:11
-
-
Save bcameron1231/db5160db9fa2e0ebc9ae5c677d00f53b to your computer and use it in GitHub Desktop.
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 (var ctx = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(newSiteUrl, clientId, clientSecret)) | |
{ | |
var pages = ctx.Web.Lists.GetByTitle("Site Pages"); | |
ctx.Load(pages); | |
//get template page | |
var templatePage = pages.RootFolder.GetFile("Project-Home.aspx").ListItemAllFields; | |
ctx.Load(templatePage); | |
ctx.ExecuteQuery(); | |
//this is our template page content | |
var _customPageHeader = templatePage[ClientSidePage.PageLayoutContentField]; //LayoutWebpartsContent | |
var _canvasContent = templatePage["CanvasContent1"]; | |
//create new page in site page library | |
var item = pages.RootFolder.Files.AddTemplateFile("/sites/test/sitepages/BeauTest.aspx", TemplateFileType.ClientSidePage).ListItemAllFields; | |
//update page header from template information | |
item[ClientSidePage.PageLayoutContentField] = _customPageHeader; | |
item[ClientSidePage.ClientSideApplicationId] = ClientSidePage.SitePagesFeatureId; //ClientSideApplicationId - b6917cb1-93a0-4b97-a84d-7cf49975d4ec | |
item["CanvasContent1"] = _canvasContent; //"<div></div>"; | |
item["_TopicHeader"] = "Service Line"; | |
item.Update(); | |
ctx.Load(item); | |
ctx.ExecuteQuery(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment