SharePoint 2010 Content Query Web Part with paging


Imtech Content Query Web Part with paging enabled One of the coolest and probably most frequently used Web Parts in SharePoint 2007 was the Content Query Web Part (CQWP) – a great control that allowed you to display content aggregations to the users. Although it was pretty awesome, it had some serious drawbacks like for example the lack of a paging mechanism – something that almost every single Web Content Management project that I worked on required. Three years later in SharePoint 2010 the CQWP got a facelift and shipped with some seriously cool features like slots and the Content to Content concept. Unfortunately still no sign of paging. So what if you want to create an aggregation of your content and page the contents? Do you have to create a custom and bad performing Web Part? Not really… Introducing Imtech Content Query Web Part v14!

Custom properties of the Imtech Content Query Web Part that provide support for paging Imtech Content Query Web Part is the solution for the lack of paging in the standard Content Query Web Part. Using the options in the properties of the Web Part, you can specify how many items you want to display per page and what the name of the query string parameter is, that holds the number of the page. So how it works?

The first thing that you need to do is to set the Page Size. By default it is set to 0 which means, that paging is disabled. The other thing that you have to do is to modify the XSL so that the Content Query Web Part becomes aware of paging and will be able to display the paging controls.

Powered by XSL

The support for paging in Content Query Web Part requires changes to two XSL files used by the CQWP: the ContentQueryMain.xsl and ItemStyle.xsl. The first configures the parameters and passes information to the Item Templates that is required in order to display the paging controls. The ItemStyle.xsl is responsible for displaying the pager control. Depending on your scenario you might either want to create a different paging control for every template or create a single one and reuse it across all templates.

To see it all working you can download the examples of the XSL files that enable paging. Simply upload them to your Site Collection and change the links in the properties of the Imtech Content Query Web Part.

Imtech Content Query Web Part Feature

Imtech Content Query Web Part is a free Web Part and you can use it without any restrictions. Please note, that it is not supported by Microsoft and you use it at your own risk.

Download: ImtechContentQueryWebPart.wsp (7KB, WSP) Download: ImtechContentQueryMain.xsl (19KB, XSL) Download: ImtechItemStyle.xsl (32KB, XSL)

And if you are interested how it all really works stay tuned for the Imtech Content Query Web Part How they do it article!

Technorati Tags: SharePoint 2010,SharePoint Server 2010,Content Query Web Part

Others found also helpful: