I have seen this asked in various places but never seen a workable solution that doesn't involve installing a new web-part (which I am unable to do).
I have a document library, which contains documents with a specific doctype which includes a value for "region".
I have managed to alter the "CustomViewFields" parameter in the .webpart file and the ContentQueryMain.xsl, Itemstyle.xsl, HeaderStyle.xsl documents and use the CQWP's grouping feature to produce the following output:
<div class="myDocuments">
<div class="group">
<h2>My region</h2>
<ul>
<li>Document 1</li>
<li>Document 2</li>
<li>Document 3</li>
<li>Document 4</li>
</ul>
</div>
<div class="group">
<h2>My other region</h2>
<ul>
<li>Document 1</li>
<li>Document 2</li>
<li>Document 3</li>
<li>Document 4</li>
</ul>
</div>
</div>
This is all well and good, but I only want to display a maximum of three documents per region ordered by date.
I haven't been able to work out any CAML query code which will achieve this, so I have been looking at using an if statement to drop any values once three have been created for the current region - but without knowing what the XML that the CQWP is exporting this is proving difficult.
At the moment this is how things are looking:
<xsl:if test="(count(preceding-sibling::Region = @Region)) < 3">
<li><xsl:value-of select="{$Region}" /></li>
<xsl:if />
Any help would be greatly appreciated before I figuratively throw SharePoint out the window!
Matt
See the sample here: http://www.novolocus.com/2009/03/10/cqwp-show-the-first-item-in-each-group/
It solved my problem in determining if the next item is already under another group/category.
HTH