Custom Content Query Web parts

Source: Internet
Author: User
Tags xsl
The Content Query Web component (cqwp) is a flexible and powerful feature provided by Sharepoint Server. With its own custom query and any queryschema supported by wss3.0 (such as caml), you can create a custom data view to display data from multiple data sources, the data can be distributed across different ranges, such as site set, site, list, and document library, and displayed in a single view.

After obtaining the queried data, cqwp does not automatically display all data items. In this case, we need to perform further customization.

Custom Content Query Web Components mainly include:
1) modify the. webpart file and customize attributes to obtain the data to be returned.
2) modify the. itemstyle. XSL style file to render and format the data.

The following is a simple demo.

Show latest knowledge baseArticleFrom shared document library
Steps:

1.Export "latest knowledge base. webpart" and back up
Click the Web Part editing drop-down button to export

2.Use Spd or notepad to open "latest knowledge base. webpart", edit the attribute "commonviewfields", and save:

< Property name = " Commonviewfields " Type = " String " > Title, text; modified, datetime </ Property >

You can use either of the following methods to define commonviewfields property:
Internal name of Field
Internal name of field, field type
Separate multiple values with semicolons (;). Note: spaces are not allowed.

3.Modify itemstyle. XSL. The file is located in the style Library style library under the root directory of the website.
Find an XSL: Template node, or create an XSL: Template
For example, find <XSL: Template Name = "imageright"> modify <Div class = "link-item">

< Div Class = " Link-item " >
< XSL: Call - Template Name = " Outertemplate. callpresencestatusicontemplate " />
< Table Style = " Width: 95% " >
< Tr >
< TD > < IMG SRC = " _ Layouts/images/square.gif " /> </ TD >
< TD Style = " Width: 60% " >
< A href = " {$ Safelinkurl} " Target = " {$ Linktarget} " Title = " {@ Linktooltip} " >
< XSL: Value - Of select = " $ Displaytitle " />
</ A >
</ TD >
< TD align = " Left " >
< Div Class = " Description " >
< XSL: Value - Of select = " @ Modified "   />
</ Div >
</ TD >
</ Tr >
</ Table >
</ Div >

4. Save andUpload itemstyle. XSL to the style Library Again
Add "latest knowledge base. webpart" to the page and modify the style attribute displayed by webpart.

Detail resources: http://msdn.microsoft.com/en-us/library/aa981241.aspx

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.