In Blogs, Mavention Make

Mavention Make can provision WebParts on a WebPart page (Content Type ID: 0x01010901).

In SharePoint you can add WebParts to for instance WebPart pages. In the example below we add new WebParts to the ‘Start.aspx’ file in the Sitepagina’s (Sitepages) library.

You can add WebParts to a WebPart page by adding the WebPart content (exported webpart) to the WebParts node of the WebPart page file object.

<Configurator xmlns="http://schemas.mavention.com/SharePoint/Apps/SiteConfigurator">
   <Providers>
      <Provider NodeName="Web" Class="Mavention.Make.Engine.Providers.WebProvider" Assembly="Mavention.Make.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a43c589e76ba4e3d" />
   </Providers>
   <Web LCID="1043" Title="{title}" Url="{url}" Template="STS#0" WelcomePageUrl="SitePages/Start.aspx">
      <Properties>
         <Property Name="WebTemplate">Projectsite</Property>
         <Property Name="WebTemplateVersion">1.0.0.0</Property>
      </Properties>
      <Lists>
         <List Url="SitePages" TemplateType="119" Title="Sitepagina's" ContentTypesEnabled="true">
            <RootFolder Name="">
               <Files>
                  <File ContentTypeId="0x01010901007B796C610D68A143A455C04F844830B4" Name="Start.aspx" Overwrite="true" FileSource="Assets/Start.aspx">
                     <WebParts>
                        <!-- Add your webparts -->
                     </WebParts>
                  </File>
               </Files>
            </RootFolder>
         </List>
      </Lists>
   </Web>
</Configurator>

In this example we will add a script editor WebPart to the WebPart page. Adding the exported WebPart data into a CDATA section and put it in a WebPart section, you can add this to the WebParts section in the example above.

<WebPart Title="Script editor WebPart" ZoneId="RightColumn" ZoneIndex="0">
<![CDATA[
<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>Kan dit webonderdeel niet importeren.</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">Hiermee kunnen auteurs HTML-fragmenten of -scripts invoegen.</property>
            <property name="Content" type="string">&lt;script type="text/javascript"&gt;alert("Hello world");&lt;/script&gt;</property>
            <property name="CatalogIconImageUrl" type="string" />
            <property name="Title" type="string">Script editor WebPart</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">Default</property>
            <property name="AllowConnect" type="bool">True</property>
            <property name="Width" type="unit">300px</property>
            <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>
]]>
</WebPart>

For some of the OOTB SharePoint WebParts there are helpers available in Mavention Make. This makes it easier to add these WebParts to the page.

Vul je zoekopdracht in.