Previously, a blog mentioned the Content Query Web Part (CQWP) in SharePoint, which means that when the anonymous access mode is enabled for SharePoint, the Content Query Web Part fails to read the Document Library data. Starting from this blog, I will talk about what Content Query Web Part can do, how to configure it, and how to customize it when necessary to meet our needs and achieve the final effect.
Now, suppose you have created your own web site through SharePoint Server 2010. All your web pages, documents, images, and other data are stored in the SharePoint Library or List, content Type defines information about different items. sub-sites is used for site structure organization and navigation. The problem is: how do you integrate some of the information points you are interested in to display them in a specific place, such as the home page?
OK, there is a OOB (Out of the box) web part in SharePoint to do this well, it is the Content Query Web Part mentioned previously. This web part allows you to capture data from somewhere on the site and display it to another place. The displayed data can be customized based on a specific query or rule. That is to say, you can control the appearance of the content to be displayed, the data items to be returned, and you can filter, group, and sort the data items. To put it simply, you can use CQWP to present the data content in different places on the site in the same place. You have control over what content to display and how to display it.
The following uses an example to describe the CQWP application. A data source is News and Events, which stores some News and Events, specifically a SharePoint List. The field information is defined as follows:
Column Name |
Column Type |
Description |
Title |
Single line of text |
News Title |
Summary |
Multiple lines of text |
News Abstract |
Learn More Link |
Hyperlink or Picture |
Detailed Link |
Featured |
Yes/No |
Control whether to display |
Sort Order |
Number |
Used to display sorting |
The purpose is to display the data in this List to the page through CQWP. Based on the above field definition, of course, the filtering and sorting functions should be included. Now, let's take a specific operation:
1. Add CQWP to the page. First, edit the page. By default, Content Query Web Part is added to the Top area of the page under the Content Rollup category:
The data source is not specified:
2. configure CQWP and edit the newly added web part. We will see a web part panel as follows, including key attributes (Query and Presentation) specific to CQWP ), and some other common attributes of the web part:
3. expand the Query attribute section, where Source is the data Source. Select the News and Events list under the root site as needed. Note that the path here uses the internal name of list, the following List Type is automatically set to Custom List, and Content Type defines the information of the data items to be displayed, because there may be multiple definitions of Content types in a list, therefore, there are many data items. The fields in the requirement are defined in the Content Type of News, so here we select News.
4. the Additional Filters section is used to set the filtering information. Here, Featured is set to Yes. Because Featured is of the Yes/No type, the following Radio Button appears by default, for other types such as Choice or Text, the following is a Textbox. If multiple filtering conditions exist, set multiple filters here.
5. Expand the Presentation attribute to set information such as grouping and sorting. Here we Sort the information by Sort Order and limit the maximum number of display items to 8:
6. click the Apply button, and then OK. We can see that data is displayed on the page. Here, only 6 data entries are displayed because only 6 data entries are added to the list, and their Featured is set to Yes, that is, display all.
Well, this time I will write it here. Basically, the configuration of CQWP is complete, and I will continue later.