When we want to deploy an OOTB webpart in a custom page layout, handy solution would be to use <AllUsersWebPart>.
Step 1:- Configure the settings of an OOTB webpart and export it.
Step 2:- Copy the contents of the webpart file.
Step 3:- Paste in Elements file of Module as given below inside <AllUsersWebpart> by specifying the webpart zone Id and Webpart order.
In below snippet i am adding OOTB Media WebPart to custom page layout
Step 1:- Configure the settings of an OOTB webpart and export it.
Step 2:- Copy the contents of the webpart file.
Step 3:- Paste in Elements file of Module as given below inside <AllUsersWebpart> by specifying the webpart zone Id and Webpart order.
In below snippet i am adding OOTB Media WebPart to custom page layout
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="PageLayouts" Url="_catalogs/masterpage" List="116">
<File Path="PageLayouts\BlankWebPartPageCustom.aspx" Url="BlankWebPartPageCustom.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >
<AllUsersWebPart WebPartOrder="0" WebPartZoneID="Header">
<![CDATA[
<webParts>
<webPart
xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type
name="Microsoft.SharePoint.Publishing.WebControls.MediaWebPart,
Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this
Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Hidden"
type="bool">False</property>
<property name="AutoPlay"
type="bool">False</property>
<property name="Height"
type="unit">360px</property>
<property name="TitleUrl"
type="string" />
<property name="Width"
type="unit">640px</property>
<property
name="MediaSource" type="string" null="true"
/>
<property name="Loop"
type="bool">False</property>
<property
name="AllowConnect" type="bool">True</property>
<property name="HelpUrl"
type="string" />
<property
name="AllowZoneChange" type="bool">True</property>
<property name="PreviewImageSource"
type="string">/sites/TestCommunity/Style Library/Media
Player/VideoPreview.png</property>
<property
name="TemplateSource" type="string" null="true"
/>
<property
name="DisplayMode" type="Microsoft.SharePoint.Publishing.WebControls.MediaDisplayMode,
Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c">Inline</property>
<property
name="ExportMode" type="exportmode">All</property>
<property name="AllowHide"
type="bool">True</property>
<property name="AllowEdit"
type="bool">True</property>
<property
name="Description" type="string">Use to embed media
clips (video and audio) in a web page.</property>
<property
name="IsPreviewImageSourceOverridenForVideoSet"
type="bool">False</property>
<property
name="AllowClose" type="bool">True</property>
<property
name="ChromeType"
type="chrometype">None</property>
<property
name="ChromeState"
type="chromestate">Normal</property>
<property
name="CatalogIconImageUrl" type="string" />
<property name="HelpMode"
type="helpmode">Navigate</property>
<property
name="TitleIconImageUrl" type="string" />
<property
name="ShowEmbedControl" type="bool">False</property>
<property
name="AllowMinimize" type="bool">True</property>
<property name="Title"
type="string">Media Web Part</property>
<property
name="VideoSetEmbedCode" type="string"
null="true" />
<property
name="VideoSetSource" type="string" null="true"
/>
<property
name="ConfigureFromContext"
type="bool">False</property>
<property name="Direction"
type="direction">NotSet</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</AllUsersWebPart>
</File>
</Module>
</Elements>
If multiple webparts has to be deployed just add more <File> tags with <AllUserWebPart> as child.
If multiple webparts has to be deployed just add more <File> tags with <AllUserWebPart> as child.
No comments:
Post a Comment