如何在 XSLT 中进行分页
我有以下 XSLT:
<xsl:template match="/">
<div id="dokumentliste">
<xsl:variable name="alleNyheder" select="$currentPage//node" />
<xsl:for-each select="$alleNyheder">
<xsl:sort data-type="text" select="@createDate" order="descending" />
<xsl:if test="./data[@alias='manchet'] != ''">
<div class="newsitem">
<h2>
<xsl:value-of select="./data[@alias='title']"/>
</h2>
<xsl:if test="./data[@alias = 'manchet'] != ''">
<div class="nyhedContent">
<p>
<span class="dokumentListeDato">
<xsl:choose>
<xsl:when test="./data[@alias='date'] != ''">
<xsl:value-of select="umbraco.library:FormatDateTime(./data[@alias='date'], 'dd. MMMM yyyy')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:FormatDateTime(./@createDate, 'dd. MMMM yyyy')"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:value-of select="./data[@alias = 'manchet']"/>
</p>
</div>
</xsl:if>
<div class="dokumentListe_laes_mere">
<a href="{umbraco.library:NiceUrl(@id)}">
Læs mere<img src="/frontend/images/macro/macro_laes_mere.png" alt="Læs mere"/>
</a>
</div>
</div>
<!-- End newsitem -->
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
我正在制作新闻列表,并且想要进行某种分页。和谷歌上看到的几乎一模一样。你知道“平常的”。
但我不知道该怎么做。
每个页面上的新闻站点数量并不那么重要,但假设每个页面上有 10 个。当显示前 10 个新闻站点时,我希望显示分页。数字右侧和左侧有“下一个”和“上一个”按钮。
是否有可能做到这一点,我是否足够好地解释了我的问题?顺便说一句,我使用 Umbraco CMS :)
非常感谢。
-金
I have the following XSLT:
<xsl:template match="/">
<div id="dokumentliste">
<xsl:variable name="alleNyheder" select="$currentPage//node" />
<xsl:for-each select="$alleNyheder">
<xsl:sort data-type="text" select="@createDate" order="descending" />
<xsl:if test="./data[@alias='manchet'] != ''">
<div class="newsitem">
<h2>
<xsl:value-of select="./data[@alias='title']"/>
</h2>
<xsl:if test="./data[@alias = 'manchet'] != ''">
<div class="nyhedContent">
<p>
<span class="dokumentListeDato">
<xsl:choose>
<xsl:when test="./data[@alias='date'] != ''">
<xsl:value-of select="umbraco.library:FormatDateTime(./data[@alias='date'], 'dd. MMMM yyyy')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:FormatDateTime(./@createDate, 'dd. MMMM yyyy')"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:value-of select="./data[@alias = 'manchet']"/>
</p>
</div>
</xsl:if>
<div class="dokumentListe_laes_mere">
<a href="{umbraco.library:NiceUrl(@id)}">
Læs mere<img src="/frontend/images/macro/macro_laes_mere.png" alt="Læs mere"/>
</a>
</div>
</div>
<!-- End newsitem -->
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
I am making a newslist, and would like to make some sort of pagination. Almost the same one as seen on Google. You know "the usual one".
But I can't figure out how to do this.
The number of newsitems on each page isn't that important, but lets say 10 on each page. When the 10 first newsitems are shown, I would like the pagination to show up. With the "Next" and "Previous" buttons to the right and the left of the numbers.
Is it possible to make this, and have I explained my problem good enough? I use the Umbraco CMS by the way :)
Thank you very much.
-Kim
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西:
我也在那里留下了一些代码来处理您列表中的图像:-)
Something like this:
I've left some code in there for dealing with images in your listing too :-)
我现在明白了这一点。我可以看到您刚刚复制/粘贴了 Tim Geyssens 制作的分页: http:// /www.nibble.be/?p=11
代码也不错,但我更改了其中一些以使其正常工作。我不知道我是否应该接受我自己的答案作为正确的答案,Myster 的答案作为正确的答案,或者我是否可以删除这篇文章?
I figured this one out now. I can see that you have just copy/pasted the pagination that where made by Tim Geyssens here: http://www.nibble.be/?p=11
And the code is also kind'a good, but I changed some of it to get it working. I don't know if I should just accept my own answer as the right one, the answer from Myster as the right one or if I can delete this post?