..:: I like SharePoint ::.. Rotating Header Image

SharePoint 2010 – Aggregate lists from all subsites

There are many posts out there about this topic. How can i roll up data from subsites from one site collection? How can i aggregate calendar entries from my subsites? Do i have to code something? How does it work? All these posts and questions leading to one question: Why is there no out-of-the-box feature which has an easy to use interface in SharePoint for that case?

Anyway, there are some possibilities to get the desired solution. It is not as easy as it could be, but you can code your own solution or you use SharePoint Designer and create a Dataview Webpart. The disadvantage is that it is only a list with all entries. I don’t know the possibility to add special views for this, for example a calendar view. I bet it is possible somehow but I still did not get it yet. So if you know how to do this, please let me know!

I recommend you to read also the post from Jennifer Hersko. She wrote some nice explanations and how to achieve it a little bit different way. Back to my solution using SharePoint Designer.

  1. Starting in SharePoint Designer by creating a new webpart page.
  2. Add an empty Data View Webpart
  3. Add a data source, in my example i used a previous created calendar
  4. Select all fields you want to insert and select multiple view

  5. Tell the dvwp where to query. Open the code view:
    1. Search for <ParameterBindings>
    2. Add after the opening tag the following parameter:
      <parameterbinding Name=”WebURL” Location=”None” DefaultValue=”/site/subsite/” />
    3. Now look for the <xsl:param tag
      Above the first parameter add this: <xsl:param name=”WebURL”>/site/subsite/</xsl:param>
  6. Now we tell the webpart what to query. We do that in the <DataSources> Tag.
    1. Change the DataSourceMode to CrossList
    2. The SelectCommand should look like this:
      SelectCommand=
      “<View>
      <Webs Scope=’Recursive’></Webs>
      <Lists ServerTemplate=’106‘></Lists>
      <ViewFields>
      <FieldRef Name=’FileDirRef’/>
      <FieldRef Name=’ID’/>
      <FieldRef Name=’Location’/>
      <FieldRef Name=’Title’/>
      <FieldRef Name=’EventDate‘/>
      <FieldRef Name=’EndDate‘/>
      <ProjectProperty Name=’Title’/>
      </ViewFields>
      <Query></Query>
      </View>”
      Some Explanations:
      List ServerTemplate is 106 for the calendar. Here you find the ServerTemplate for other Lists.
      EventDate is the starting Date. EndDate the ending Date. The background has to deal with static name vs. display name.
      The ProjectProperty will display the source from which subsite the data is rolled up.
    3. Now the webpart should already display data from all sites of the site collection.
  7. You can see that the event title does not link to the item. Therefore search for select=”@title”
    1. Replace the xsl:value tag with the following:
      <a><xsl:attribute name=”href”>/<xsl:value-of select=”substring-after(@FileDirRef,';#’)” />/Dispform.aspx?ID=<xsl:value-of select=”@ID” /></xsl:attribute><xsl:value-of select=”@Title” /></a>
  8. As I told you the ProjectProperty display the sitename of the entry. To display this you should perform the following steps:
    1. Click in the ribbon on Add/Edit columns
    2. Add ProjectProperty.Title
    3. Select the xsl:value of the ProjectProperty and replace it with this:
      <xsl:value-of select=”substring-after(@[ProjectProperty.Title],';#’)” />
  9. Finished

Now you should see you solution in the browser similar to this:

As a new subsite will be added and you add a calendar with entries, these items will be displayed also in this webpart. How cool is that?

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

4 Comments

  1. Waldek says:

    Hi Karsten
    Vey good article .
    Could you pls advise how to for Project.Ttile ( site name ) make link pointing to the subsite ?

    1. Hi Waldek,
      look at http://sympmarc.com/2009/02/26/10065/ there might be the hint. Try to use projectproperty.url.
      Does it work?

  2. Ashok Mandial says:

    Hi Karsten,

    I have similar requirement to get aggregated list data for subsites. The solution will have a list of sites to aggregate, it will contain the URL’s to the sites. It will use this list of sites to create an aggregate of all of the content into a single list. The sites being aggregated will have two columns, Title and Description.

    After the content has been aggregated, i would like to have a search box that a user can enter text, and it will search the aggregated list, and then present the results organized in groups by site title.

    Can you please guide me on this?

    Thanks in advance!

    1. Hi Ashok,
      if i get your right, you wanna have a list of all subsites? What content should be aggregated? It is a tasklist or what kind of stuff?
      What i would try is using Sharepoint Designer and create the view in a dataview webpart like you want it with grouping and sorting. After that you could try to build it up with the crosslist function like in the post.

      Another approach might be to use the search core result web part and change the display template of the result to your needs. There should be some instructions in the web i guess.
      Hope this helps.
      regards
      Karsten

Leave a Reply

Your email address will not be published. Required fields are marked *


three × seven =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>