Display Multiple Document Libraries in SharePoint 2010
A few years ago, I wrote an article for SPTechWeb, where I give a high level overview of several different ways to display content from multiple document libraries. Here’s the article.
A frequent requirement in SharePoint projects is to display documents from multiple libraries together. There are several different methods in which this can be achieved in SharePoint 2010, ranging from simple out-of-the-box Web parts to more advanced data view Web parts. Of course, as with most tasks in SharePoint, it can be done with custom development, but I usually try to steer towards out-of-the-box functionalities before going that route.
In this article, you will learn about several different methods for displaying documents from multiple libraries, with pros and cons of each method.
Relevant Documents Web Part
This is an out-of-the-box Web part. It shows a rollup of files that are relevant to you. It is in the Content Rollup category of Web parts. By default, this Web part shows all documents in the site that were last modified by me (the currently logged-in user). In the Web part settings, there are check boxes to allow the display of documents created by me and documents checked out to me:
• Pros – It displays the most recent data from multiple libraries on a site, and it is automatically personalized to the logged-in user.
• Cons – There is not much customization that can be done in the Web part settings, it will only display information relevant to whomever is currently looking at the page, and it only rolls up data from one site.
Content Query Web Part
This is another out-of-the-box Web part. This Web part is only available when the publishing features are enabled at the site-collection level. This Web part is also in the Content Rollup category of Web parts.
With this Web part, a specific type of content can be selected and rolled up from the level of your choosing: the whole site collection, one site, or one specific list. The format of the display can also be configured in the Web part settings, such as changing the grouping level and the style of the text for groups and items. In this example, all tasks from the site collection are displayed in one place on the home page. This Web part can even accept up to two filters, so if desired this Web part could be filtered so that “Assigned To” is equal to Me, and the logged-in user would see all of their tasks.
• Pros – A fair amount of customization can be done in the Web part settings, and content can be rolled up from multiple sites.
• Cons – The performance on this Web part is not optimal. For example, if it is set up to roll up all documents from libraries in 100 different sub-sites, this Web part could take a bit long to load. Another issue is that by default this Web part displays the title field of items. The display format and columns CAN be customized, but it takes modification of the itemstyle.xsl and levelstyle.xsl files in the Style Library (document library) on the site, which takes some coding knowledge.
What’s New Web Part
This is an out-of-the-box Web part. It is only available when the Group Work Lists feature has been activated on the site. This Web part displays items that have been created or modified in the last seven days. In the Web part settings, pick the specific lists and libraries to display, and they are all rolled up in the Web part.
• Pros – It can roll up the specific lists and libraries of your choosing from one site, and it is a good, quick glimpse at items that people have been working on lately.
• Cons – There aren’t many customizations that can be made in the Web part settings, and the setup is a bit complex because the modified column needs to be set up as indexed on each list or library that needs to be included. Here is a blog post that I wrote all about the “What’s New” Web part.
Data View Web Part—Merge Sources
This is a Web part that can be created as a data view Web part using SharePoint Designer 2010. With this method, specific libraries can be selected from within the site and merged together to create one big list of documents. In SharePoint Designer 2010, open your site and click Data Sources on the left. In the ribbon, click Linked Data Source. Click Configure Linked Source, and there you will be prompted to select from any of the lists and libraries on the site.
Click Next, choose Merged source, click Finish and click OK. This article is not a deep dive into the specifics, but what you would next open a Web part page in SharePoint designer and insert this new source onto the page. This data view Web part would display one big list of documents. This can be done in any version of SharePoint, including Foundation.
• Pros – Specific columns, grouping, sorting and filtering by metadata can all be configured using SharePoint Designer. There is no programming required.
• Cons – The SharePoint Designer software must be installed, and the user creating the Web part must have access to use this program. Basic understanding of SharePoint Designer and data view Web parts is helpful. Here is a video that I recorded about how to create a data view Web part with merged libraries. It was created in 2007, but the concepts are the same.
Data View Web Part—Content Rollup
This is another Web part that can be created as a data view Web part using SharePoint Designer 2010. This Web part will roll up all content of any one content type. Some code tweaking in the HTML of the page is necessary for the functionality, but once this has been done, it will show a rollup of all items of a given content type. This can be done in any version of SharePoint, including Foundation.
• Pros – When new libraries are added, this Web part does not need to be modified; they are automatically rolled up.
• Cons – This Web part has some restrictions when it comes to the site columns that are used in the content type, and the steps to get it working correctly are a bit cumbersome. And, as with the merged sources, SharePoint Designer is required.
Data View Web Part—Search Results
This last method of displaying rolled up information is the most complex of all of the other methods listed. When it comes to performance, though, this Web part is the most efficient. The creation of this Web part involves another data view Web part in SharePoint Designer, but for the rollup, it utilizes the search results Web part. This is an enterprise-only Web part and is not available in other versions of SharePoint. The efficiency of this Web part lies in the fact that it does not perform the query each time the page is loaded. The query and retrieval of the data is done when SharePoint search indexes the content source.
• Pros – This is the most efficient content rollup. Customize the results as desired by selecting any columns, sorting and filtering.
• Cons – This is a more technical procedure, and it requires a more intimate understanding of data and XSLT. It also of course requires the use of SharePoint Designer. Here is a blog post that I wrote about how to use the search results Web part in this manner, in 2010. You can look forward to the fact that SharePoint 2013 enterprise has an out-of-box web part “Content Search” that does this same thing. I hope this article has shed some light on different ways to view data from multiple libraries in SharePoint 2010.