CQWP Banding using XLST
The Content Query Web Part aggregates SharePoint content. Banding can be added by customizing the associated XSLT in a file called ItemStyle.XSL.
One can optionally customize the XSL in a copy of this file and then customize the CQWP to use the customized file. I wanted to customize the list of Blog posts to be condensed, with a truncated preview.
Here’s how to do it.
Tuning the CQWP
Use the following settings in the CQWP to create a list of just Blog Post Links:
- List Type: Posts
- Content Types: List Content Types
- Show items: Post
- Group by: Created By
- Sort by: Created
- Limit: 25
- Group style: Banded
- Item Style: Title Only: Important, this determines the XSLT template customized and used later
- Fields to display: Title: Title (only)
Optional:
- Export Web Part
- Open in Notepad
- Edit and change the XSLT file ItemStyle.XSL referenced, to point to a different file
- Save
- Import as a web part
Tuning the XSLT
Locate the XSLT template processing the item, and refine it. If a new XSL file is desired, copy ItemStyle.XSL and edit that one. Here’s the customized commented code for the TitleOnly template:
<!-- Joel's alternating row colorings--> <!-- Joel's table, created for each row, 300 wide seems a good number --> <!-- Joel's decision to use the existing 'description' class, to get more vertical compression than 'tem'--> <!-- Joel's create a table, row and cell around each link, to allow banding --> |
Want to talk?
Drop us a line. We are here to answer your questions 24*7.