0

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)) &lt 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

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
Matt Bunce
  • 87
  • 1
  • 7
  • This isn't a complete question. Please, specify the complete (but as small as possible) XML document and the complete (but as small as possible) wanted result amd clearly state what you want the transformation to do/achieve. – Dimitre Novatchev Dec 12 '10 at 15:08
  • 2
    Kindly provide the xslt you are using so that i can modify and send you the correct one – Ashutosh Singh-MVP SharePoint Dec 12 '10 at 15:38
  • This is where is gets tricky - since it is the output of an Sharepoint web part I am not entirely sure what the XML looks like - it's almost like trying to write XSLT blind. Coupled with the fact that SharePoint calls three different XSLT files to process different section of its result it makes trying to give sample data very difficult. I will go away and try to figure out what SharePoint is doing with the data and then share some test data. – Matt Bunce Dec 17 '10 at 22:52

1 Answers1

1

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

tousle
  • 110
  • 1
  • 1
  • 7