SharePoint 2010's Content Query Web Part - dummies

SharePoint 2010’s Content Query Web Part

The Content Query Web Part is one of three Web Parts provided by SharePoint 2010’s publishing sites to display content. The Content Query Web Part allows you to display content from anywhere in your site collection; it’s useful for rolling up content to a home page or creating an archive view of content.

The Content Query Web Part is commonly used to display a list of news articles on a site’s landing page (the first page visitors usually arrive at). Say you have three people creating new articles in your site. You can use the Content Query Web Part to automatically display a list of these articles on your department’s landing page.

Follow these steps to use the Content Query Web Part:

  1. Insert the Content Query Web Part into your page and edit the Web Part’s properties.

    The Content Query Web Part is located in the Content Rollup section.

  2. In the Query section of the Web Part, select the options that will return the items you wish to see in the Web Part.


    The Query section provides many options, including:

    • Source: Select the location in your site hierarchy where you want to query items. If you want to display items regardless of where they appear in your site hierarchy, select the Show Items from All Sites in This Site Collection radio button and select the List Type, Content Type Group, and Content Type you want to display.

      For example, if you want to roll up all project tasks, use your Tasks List Type and List Content Type Group and Task Content Type.

    • List Type: Select the kind of list that stores your items from the drop-down list.

    • Content Type: Select the content type group and content type you want to use for query from the drop-down lists.

    • Audience Targeting: If you want the Web Part to honor any audience targeting settings on the items, select the Apply Audience Filtering check box.

    • Additional Filters: Include any additional fields on which you wish to filter by selecting from the drop-down lists. The list of available fields is determined by the list type and the content type.

      For example, to display all tasks that aren’t started, choose Task Status, Is Equal To, and Not Started from the drop-down lists.

      You can configure more query options for the Content Query Web Part with SharePoint Designer 2010.

      Behind the scenes, this Web Part generates a query with SharePoint’s query language, CAML (Collaborative Application Markup Language). You can write your own custom CAML query to use instead of selecting the options; you can find sites that tell you more about CAML by searching “CAML syntax” in your favorite search engine.

  3. In the Presentation section of the Web Part, select the options that will display your items.


    • Grouping and Sorting: Select the columns by which you wish to group results in the Group Items By drop-down list. You can also choose to group results by site by selecting the Site option in the Group Items By drop-down list.

      You can select a column to sort by and limit the number of items displayed by choosing the Sort Items By drop-down list and selecting the Limit the Number of Items to Display check box, respectively, and then entering a number in the Item Limit field.

    • Styles: Select the group style and item style you want to use to display your items from the Group Style and Item Style drop-down lists.

      These styles determine what information appears. For example, Title and Description displays the item’s title field, linked to the document or item, along with the description.

      These styles are XSL templates, not CSS styles. You can create your own XSL templates using SharePoint Designer 2010.

    • Fields to Display: Specify the fields that you want to map to the item style you select by typing them in the Fields to Display text boxes.

      In the case of most documents and articles, the Comments field is the default description field. For items, you have to decide which field you want to use. For example, the Tasks content type uses the Body field. Enter the field name Body in the Description field and the value of that field appears in the Web Part.

    • Feed: Indicate whether you want an RSS feed to be generated for the results of this query by selecting the Enable Feed for This Web Part check box.

  4. Click OK.

    Your query appears in the Web Part.