Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a working macro that asks the user to select a node from the media library and then it displays the title of each file within the node.
I have a new need to only display the most recent 5 files within the node, not all of them.
I'm new to XSLT and I'm having trouble with how to create this loop.
Here's what I currently have (that displays all items):
<xsl:template match="/"> <ul> <!-- Loop through nodes and show all --> <xsl:for-each select="$documents"> <xsl:sort select="./@createDate" order="descending" /> <xsl:if test="number(current()/data [@alias='umbracoBytes']) > 0"> <li><a href="{current()/data [@alias='umbracoFile']}"><xsl:value-of select="./@nodeName"/></a> </li> </xsl:if> </xsl:for-each> </ul>
Any help or suggestions?!
Hi Asad
While it's been a while forgive me if my memory is wrong but I think you need to write something like
<xsl:if test="position() < 6"></xsl:if> to only have top 5 recent nodes. So your example would look like this
<xsl:if test="position() < 6"></xsl:if>
<xsl:template match="/"> <ul> <!-- Loop through nodes and show all --> <xsl:for-each select="$documents"> <xsl:sort select="./@createDate" order="descending" /> <xsl:if test="position() < 6"> <li><a href="{current()/data [@alias='umbracoFile']}"><xsl:value-of select="./@nodeName"/></a> </li> </xsl:if> </xsl:for-each> </ul>
Does this work for you?
/Jan
By golly, I knew it was something simple! Thank you. This worked perfectly.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Macro that Loops Through Media Node "N" Times and Prints
I have a working macro that asks the user to select a node from the media library and then it displays the title of each file within the node.
I have a new need to only display the most recent 5 files within the node, not all of them.
I'm new to XSLT and I'm having trouble with how to create this loop.
Here's what I currently have (that displays all items):
Any help or suggestions?!
Hi Asad
While it's been a while forgive me if my memory is wrong but I think you need to write something like
<xsl:if test="position() < 6"></xsl:if>
to only have top 5 recent nodes. So your example would look like thisDoes this work for you?
/Jan
By golly, I knew it was something simple! Thank you. This worked perfectly.
is working on a reply...