2013-11-26

In Office 365 / SharePoint online,  a publishing page with a list of views pointing to a different list can be provisioned using a feature containing a File element containing a view.

Example:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="ModuleName" Url="$Resources:cmscore,List_Pages_UrlName;">
<File Url="default.aspx" Type="GhostableInLibrary" Path="ModuleName\default.aspx" IgnoreIfAlreadyExists="TRUE" >
<Property Name="Title" Value="Home" />
<Property Name="IncludeInGlobalNavigation" Value="FALSE" />
<Property Name="ContentType" Value="ContentTypeName" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PageLayout.aspx, PageLayout" />
<View List="Lists/MyTasks" BaseViewID="0" WebPartZoneID="Main" WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="AllowConnect" type="bool">True</property>
<property name="ChromeType" type="chrometype">TitleAndBorder</property>
<property name="AllowClose" type="bool">False</property>
<property name="Title" type="string">Tasks</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
</File>
</Module>
</Elements>

Note:

<View List="Lists/MyTasks" BaseViewID="0" ....></View> - represents a view in a List "MyTasks". This can be changed to a different view.
The above can also be achieved using the AllUsersWebPart by initialising all the relevant properties.
<AllUsersWebPart WebPartZoneID="wzMain" WebPartOrder="2">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="ShowWithSampleData" type="bool">False</property>
<property name="Default" type="string" />
<property name="NoDefaultStyle" type="string" null="true" />
<property name="CacheXslStorage" type="bool">True</property>
<property name="ViewContentTypeId" type="string" />
<property name="XmlDefinitionLink" type="string" />
<property name="ManualRefresh" type="bool">False</property>
<property name="ListUrl" type="string" >Lists/Tasks</property>
<property name="TitleUrl" type="string">/Lists/Tasks</property>
...
</properties>
</data>
</webPart>
</webParts>
]]>
</AllUsersWebPart>

 
<!–[CDATA[

Cannot import this Web Part.

False

True

False
Lists/Tasks
/Lists/Tasks

]]>

About the author 

Balamurugan Kailasam