I’ve seen this come up numerous times (with a few people telling me “it’s not possible without writing code”) so I thought I’d show a simple code sample of how this is done in SharePoint 2013.
Let’s say you want to add some List View Web Parts to a custom Team Site for a Tasks list:
- My Tasks
- Tasks In Progress
- Tasks Overdue
You would initially do this kind of thing in your onet.xml:
<View List="Lists/Tasks" BaseViewID="1" WebPartZoneID="Header" /> <View List="Lists/Tasks" BaseViewID="2" WebPartZoneID="Header" /> <View List="Lists/Tasks" BaseViewID="3" WebPartZoneID="Header" />
Of course the main problem here is that you have zero control over any of the Web Part properties (such as the Title, border, or anything else). The default title will use the same title as the list, which of course (when you have the same list more than once) offers the stunningly un-useful:
- Tasks (1)
- Tasks (2)
- Tasks (3)
The solution is to include some additional Web Part properties in embedded CDATA tags:
This gives you effectively complete control over any of the Web Part Properties (see XsltListViewWebPart Properties).
By Martin Hatch, Associate Principal SharePoint Consultant
Have a comment? Let us know below, or send an email to email@example.com