Forum Discussion

David Moore's avatar
David Moore
Copper Contributor
Sep 29, 2016

OfficeDev PnP - Provision Page content?

I know there's a <pnp:Pages> element in the schema, but it seems to only provision web part XML. Is there any way to add just HTML to a wiki page content, rather than having to wrap it in a Content Editor Web Part?

 

Cheers!

  • David,

     

    What you could do is use a current team site, with a wiki page as welcome page. Add some text/html to this page and use below powershell command to extract this site as template:

     

    Connect-SPOnline -Url "Url to your team site"
    Get-SPOProvisioningTemplate -Out "C:\temp\teamsite.xml

     

    Within the extracted template, lookup your page (pnp:Pages element). Within the page there should be a Field called 'WikiField'. Your html is in here. So to put html in a page and provision it within a template: put it in this field.

     

    <pnp:Field FieldName="WikiField"><![CDATA[<div class="ExternalClass972799D44F734918B33EB6504C516F27"><table id="layoutsTable" style="width&#58;100%;"><tbody><tr style="vertical-align&#58;top;"><td style="width&#58;100%;"><div class="ms-rte-layoutszone-outer" style="width&#58;100%;"><div class="ms-rte-layoutszone-inner" style="min-height&#58;420px;"><p>This is some test <strong>text.</strong><br></p></div></div></td></tr></tbody></table><span id="layoutsData" style="display&#58;none;">false,false,1</span></div>]]></pnp:Field>

     

  • you could do it like this: 

         <pnp:WebPart Column="1" Row="1" Title="Script Editor">
                  <pnp:Contents>
                    <webParts>
                      <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                        <metaData>
                          <type name="Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
                          <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                        </metaData>
                        <data>
                          <properties>
                            <property name="ExportMode" type="exportmode">All</property>
                            <property name="HelpUrl" type="string" />
                            <property name="Hidden" type="bool">False</property>
                            <property name="Description" type="string">Allows authors to insert HTML snippets or scripts.</property>
                            <property name="Content" type="string">
                              Add some project info here.&lt;br /&gt;&lt;br /&gt;
                              &lt;div style=&quot;float:left; width:150px; padding-right:12px;&quot;&gt;
                              &lt;div &gt;
                              &lt;a href=&quot;{SiteCollection}/TEN&quot; title=&quot;test&quot;&gt;
                              &lt;img width=&quot;150&quot; height=&quot;124&quot; src=&quot;{SiteCollection}/SiteAssets/Tiles/test.jpg&quot;/&gt;
                              &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;div&gt;
                              &lt;a href=&quot;{SiteCollection}/TEN&quot; title=&quot;test&quot;&gt;
                              &lt;h2 style=&quot;text-align:center;&quot;&gt;test&lt;/h2&gt;
                              &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div style=&quot;float:left; width:150px; padding-right:12px;&quot;&gt;
                              &lt;div &gt;
                              &lt;a href=&quot;{SiteCollection}/EXE&quot; title=&quot;Execution&quot;&gt;
                              &lt;img width=&quot;150&quot; height=&quot;124&quot; src=&quot;{SiteCollection}/SiteAssets/Tiles/EXE.jpg&quot;/&gt;
                              &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;div&gt;
                              &lt;a href=&quot;{SiteCollection}/EXE&quot; title=&quot;test&quot;&gt;
                              &lt;h2 style=&quot;text-align:center;&quot;&gt;test&lt;/h2&gt;
                              &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div style=&quot;float:left; width:150px; padding-right:12px;&quot;&gt;
                              &lt;div &gt;
                              &lt;a href=&quot;{SiteCollection}/CLO&quot; title=&quot;test&quot;&gt;
                              &lt;img width=&quot;150&quot; height=&quot;124&quot; src=&quot;{SiteCollection}/SiteAssets/Tiles/test.jpg&quot;/&gt;
                              &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;div&gt;
                              &lt;a href=&quot;{SiteCollection}/CLO&quot; title=&quot;test&quot;&gt;
                              &lt;h2 style=&quot;text-align:center;&quot;&gt;test&lt;/h2&gt;
                              &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;/div&gt;
                            </property>
                            <property name="CatalogIconImageUrl" type="string" />
                            <property name="Title" type="string">Script Editor</property>
                            <property name="AllowHide" type="bool">True</property>
                            <property name="AllowMinimize" type="bool">True</property>
                            <property name="AllowZoneChange" type="bool">True</property>
                            <property name="TitleUrl" type="string" />
                            <property name="ChromeType" type="chrometype">None</property>
                            <property name="AllowConnect" type="bool">True</property>
                            <property name="Width" type="unit" />
                            <property name="Height" type="unit" />
                            <property name="HelpMode" type="helpmode">Navigate</property>
                            <property name="AllowEdit" type="bool">True</property>
                            <property name="TitleIconImageUrl" type="string" />
                            <property name="Direction" type="direction">NotSet</property>
                            <property name="AllowClose" type="bool">True</property>
                            <property name="ChromeState" type="chromestate">Normal</property>
                          </properties>
                        </data>
                      </webPart>
                    </webParts>
                  </pnp:Contents>
                </pnp:WebPart>

Resources