CQWP:每组显示 n 个项目
我在不同的地方看到过这个问题,但从未见过不涉及安装新的 Web 部件(我无法做到)的可行解决方案。
我有一个文档库,其中包含具有特定文档类型的文档,其中包含“区域”值。
我已设法更改 .webpart 文件和 ContentQueryMain.xsl、Itemstyle.xsl、HeaderStyle.xsl 文档中的“CustomViewFields”参数,并使用 CQWP 的分组功能生成以下输出:
<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>
这一切都很好,但我只想显示每个区域最多三个文档(按日期排序)。
我无法制定任何可以实现此目的的 CAML 查询代码,因此我一直在考虑使用 if 语句在为当前区域创建三个值后删除任何值 - 但不知道该 XML 是什么CQWP 正在出口,这被证明是困难的。
目前情况是这样的:
<xsl:if test="(count(preceding-sibling::Region = @Region)) < 3">
<li><xsl:value-of select="{$Region}" /></li>
<xsl:if />
在我象征性地将 SharePoint 扔出窗外之前,任何帮助将不胜感激!
马特
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅此处的示例: http ://www.novolocus.com/2009/03/10/cqwp-show-the-first-item-in-each-group/
它解决了我确定下一个项目是否已经在另一个组下的问题/类别。
华泰
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