Live from SPC11 : Content Query WebPart: A Deep Dive on SharePoint’s Swiss Army Knife WebPart

Written by Yves

October 6, 2011

<Disclaimer>This is personal notes of what I retained during the session. This can be incomplete, partially right or wrong. It is just part of the notes I took and what retained my attention. Nothing prevents the user to get more information on their favorite web site.</Disclaimer>

CQWP is part of the Publishing infrastructure and therefore of the SharePoint Server edition. It is used to rollup content, from a single list to a complete site collection. It allows to filter by content type.

About 60 properties and methods are available. CQWP can be exported, modified and imported again in a web part zone of a page.

When naming a column, avoid spaces and special characters. CommonViewFields specify the fields to request and that is where you specify the additional fields. QueryOverride bypasses limtes to query behavior imposed by the UI. WebsOverride makes the CQWP not recurse.

When selecting a site as a source, it will recurse, from that site, through all its subsites. In List Type, you select the list template you want to get the content from. It is also possible to filter based on the content type. It is also possible to filter on field values. AdditionalFilterFields can be used to go beyond the limit of 3 fields imposed by the UI.

It is possible to specify the CommonViewFields in two format : internal field name or added with the type separated by a comma. To represent a space use _x0020_ . To combine fields, separate them with a semicolumn.

DataColumnRename rename columns programatically and helps minimizing the XSLT.

Three XSL files : ContentQueryMain.xsl, ItemStyle.xsl and Header.xsl. All located in the Style Library\XSL Style Sheets. This last folder only exists if the Publishing feature is activated.

ContentQueryMain.xsl calls the Header and Item templates for each item. It receives all the content.

ItemStyle.xsl is applied to row items (Item Style in the UI)

Header.xsl contains the group styling (Group Style in the UI)

On pages, you can put some content that will actually not be displayed on the page when browsing, but will be when the CQWP rolls up the page.

It is recommended to not customize the out-of-the-box files, but rather make a copy and use it. When the CQWP takes the content that is HTML, the CQWP does not interpret the HTML.

You May Also Like…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *