Forum Discussion
Danny Foncke
Feb 16, 2017Copper Contributor
PnP Provisioning Engine template support for publishing pages ?
Is there any news on the support for publishing pages by the pnp provisioning engine.
if this functionality is not for the near future, any suggestions on how best to complement the provisioning (the provisioning is done using the powershell cmdlets)
Thanks
17 Replies
Sort By
- paulpaschaBronze Contributor
You can provision Publishing Pages using PnP, see an example below:
<pnp:File src="mypublishingpage.aspx" Folder="{site}/Pages" Overwrite="true"> <pnp:Properties> <pnp:Property Key="ContentTypeId" Value="{contenttypeid:MyPageContentType}" /> <pnp:Property Key="Title" Value="My Publishing Page" /> <pnp:Property Key="PublishingPageLayout" Value="{sitecollection}/_catalogs/masterpage/MyPageLayout.aspx, My Page Layout" /> </pnp:Properties>
</pnp:File>In this example a Publishing page with the filename mypublishingpage.aspx is provisioned to the pages library using the specified Content Type and Page Layout.
Are there any specific challenges you face when provisioning Publishing Pages?
- BrianPMcCullough00Copper Contributor
Can you point to a sample set of files (template.xml and any others needed) to deploy a publishing page? I am trying to do it using the <pnp:File>, but I get an ArgumentNullException related to the "stream" parameter of the "Microsoft.SharePoint.Client.FileFolderExtensions.UploadFile" using an XML structure very similar to that which you provide (btw - typo in the "src" attribute - should be "Src").
Do I need a local file matching the "Src" attribute for upload. Perhaps with the TemplateRedirect content in it?
<%@ Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage, Microsoft.SharePoint.Publishing,Version=15.0.0.0,Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Reference VirtualPath="~TemplatePageUrl" %> <%@ Reference VirtualPath="~masterurl/custom.master" %>
- BrianPMcCullough00Copper Contributor
FYI...I put a file with the name matching the Src in the same directory as the template XML file and filled it with the TemplateRedirect stuff. That seems to do the trick! I even pushed with a ScriptEditor web part also!
- BrianPMcCullough00Copper Contributor
Is there a way to get web parts in zones on the pages as well? I didn't think this was supported yet.
- paulpaschaBronze Contributor
In my experience adding WebParts to Publishing Pages works just fine by including a definition like below in your pnp:File
<pnp:WebParts> <pnp:WebPart Order="0" Title="Your WebPart Title" Zone="Center"> <pnp:Contents> <!-- your exported WebPart XML --> </pnp:Contents> </pnp:WebPart> </pnp:WebParts>
- Danny FonckeCopper Contributor
Thanks for the quick response Paul :)
I provision a site using the pnp get...template and apply...template powershell cmdlets.
I noticed that publishing pages are not included in the template.
Hence the first part of my question : is this coming in the near future.
Second part : If I have to do it myself, what is the best method taking into account that I want to 'copy' an existing page (in a source site) to a target site.If so advisable I can get... the template, add xml to it manually, and then use that extended template to provision the pages.
I will need to come up with the xml that provisions everything as is on the source page.Thanks again.
- paulpaschaBronze Contributor
Ah I see what you mean...
I don't know about planned support. Maybe VesaJuvonen can share some info on this....
We've done quite a few custom development projects in which defining our templates with Publishing Pages was largely a manual proces.