3

I am trying to create a page layout with an XsltListViewWebPart that, no matter what site collection or subsite you're on, so long as that web has a list with that name, it will use it.

At the moment, using recommended methods, I receive "List not found" on sub-sites. Site collection root webs work just fine.

Within Elements.xml, embedded with the page layout definition:

<AllUsersWebPart WebPartZoneID="zoneidhere" 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="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/MyList</property>
      <property name="TitleUrl" type="string">Lists/MyList</property>
      <property name="Title" type="string">List Title</property>
      <property name="AllowEdit" type="bool">True</property>
      </properties>
      </data>
      </webPart>
      </webParts>
      ]]>
  </AllUsersWebPart>

I have also tried without the ListUrl and TitleUrl, and instead used ListDisplayName set to "MyList" which gave the same "List not found" results on subwebs.

Any ideas?

2 Answers 2

0

I think you have to mention the WebId property aswell, this ID is the ID of the subweb where your list is located. The listurl is then still relative to the subsite url

<property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">820a89d6-8509-4bc4-9d39-4fd91e420f7a</property>
0

Here is the solution I did for this type of scenario. I browser the target list using Sharepoint Designer, went to "views" and lets say you want to use the "allitems" view: edit that view and copy the piece of code that starts with:

<WebPartPages:XsltListViewWebPart runat="server" ViewFlag="" ViewSelectorFetchAsync="False" InplaceSearchEnabled="True" Ser...

Paste this code in your page layout and all done. Then you can filter and modify it changing the params.

You could also export the webpart to the site gallery webpart.

For more details, please read this post

Cheers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.