How to configure and customize Content Query Web Part in SharePoint (2)

Source: Internet
Author: User
Tags xsl xsl file xslt

Previously, a blog completed the Content Query Web part configuration. Using this blog, we can easily retrieve data from the Sharepoint list and display the data on the page. The results are as follows:

Although the data is read, how can we customize the layout and style of the item to meet our needs? This blog will take you to complete the custom work. In fact, the way to complete this task is to modify the XSLT related to this Web part to format the data. First, there are three XSLT files related to the Content Query Web part, as shown below:

File Name

Directory

Description

Contentquerymain. XSL

/Style Library/XSL style sheets/contentquerymain. XSL

This file is used to take charge of the overall structure of the Web part. It defines some logic and functions and calls header. XSL and itemstyle. XSL when appropriate.

Itemstyle. XSL

/Style Library/XSL style sheets/itemstyle. XSL

This file is used to define the style of each item. Some styles are pre-defined for our use, and the item style can be customized.

Header. XSL

/Style Library/XSL style sheets/header. XSL

This file defines how the template displays headers and ensures the consistency of all group headers.

In most cases, we only need to care about the itemstyle. XSL file. Of course, there may be changes to the other two files according to the project's needs. Here we only need to modify itemstyle. this file is XSL, because these three files are built-in by default. In order not to affect other Web parts, we need to create a folder separately, copy a copy to our folder and make custom modifications. The procedure is as follows:

1. Open the site with SPD, create a folder named newsandevents in the/Style Library/XSL style sheets/directory, and copy the three files above to the folder:

2. export the Web Part configured on the page to the local disk, and modify the paths of the three XSLT files and the attributes of commonviewfields, modifying this attribute mainly adds custom fields so that they can be referenced in XSLT before being render to the page, because the Web part has four fields by default: title, description, linkurl, and imageurl, therefore, we only need to add other custom fields used in XSLT in the format of "internalname, fieldtype". Separate multiple fields with semicolons, as shown below:

<property name="MainXslLink" type="string">/Style Library/XSL Style Sheets/NewsAndEvents/ContentQueryMain.xsl</property>
<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/NewsAndEvents/ItemStyle.xsl</property>
<property name="HeaderXslLink" type="string">/Style Library/XSL Style Sheets/NewsAndEvents/Header.xsl</property>

<property name="CommonViewFields" type="string">LearnMoreLink,URL;Summary,Note;</property>

3. Save the modified Web part, import it to the page, and change the title of the Web part to "News browsing"

4. Modify the itemstyle. XSL file to add our custom itemstyle, including the layout and style as follows:

5. Expand the presentation attribute in the Web part on the Edit page. In the item style drop-down box, select the newly defined newsitemstyle.

6. Save the Web part and check in the page. Then we can see the layout and style we want:

Okay. Write it here this time and continue later.

From: http://blog.csdn.net/crazysharepoint/article/details/6308669

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.