SharePoint Content Query Web Part for MOSS 2007
SharePoint’s Content Query Web Part is an underrated feature that can easily be deployed to allow queries from multiple lists. While this may sound not too exciting, in actuality there are a number of really clever uses for Content Queries. For example, you can have a Content Query that displays all files that have been changed in the repository each day. Or a master list of the contents of several pages and sites. Or a list of all files modified by a particular user, or those that contain specific keywords, or any number of complex queries.
To add the Content Query Web Part to your MOSS 2007 sites, follow these steps:
- Under Site Actions click Create Page
- Under Web Pages click on Web Part Page:
- Enter a title for the new Content Query Web Part and in the Layout section select the design of the page you want to create:
- From the new page that then appears, click the Add a Web Part link
- Under All Web Parts, under the Default section, check Content Query Web Part:
- Click Add and the new Web Part appears on the page
The steps above create the Content Query Web Part. Now, it needs customizing to show what you want to see. To do this, you decide what to query (a single list, an entire site, of a collection of sites) and whether to query by list type or list content. You can also create filters to narrow results to your criteria. As a last step, you can format the Web Part to control the display of the resulting information.
The exact customization depends on what you are trying to display, but an example will show the process. In the example Content Query Web Part below, we display all documents modified by a specific user in all the sites in the current site collection. The steps to customise the Web Part are:
- From the Content Query Web Part page you created, click the Edit button on the right of the title bar and select Modify Shared Web Part
- This will display a page with the Web Part in the left pane, and a set of parameters in the right pane. You can click on any of the items on the right pane to expand and set parameters:
- Under Query, click Show items from all sites in this site collection
- In the List Type section, click Document Library
- In the Content Type section, under Show items of this content type group select Document Content Types
- In the Additional Filters section under Shows items when click Name, then in the next field select Equal To, then enter the user ID you want:
- Click OK and the Web Part is completed.
You can create additional Web Parts on the same page, each with customized Content Queries, or you can set up different pages as you need. Working with Content Query Web Parts is easy to do, and allows you to customize your pages to show exactly what you need.