Hoping someone can give my brain a jumpstart today.
Via XSLT,
how do I get the node ID of a content item, where a property (photo) is not empty...
sort the results by a date property and get the one, most recent node?
You need to do the position-test inside the loop (essentially after the sorting) and not when selecting the nodes to iterate (your for-each only iterates the first item), e.g.:
<xsl:for-each select="$currentPage//*[@isDoc][normalize-space(photo)]">
<xsl:sort select="publicationDate" data-type="text" order="descending" />
<xsl:if test="position() = 1">
<!-- Do something with the current node here -->
</xsl:if>
</xsl:for-each>
I'm guessing you need the ID to do the rendering - but just so you know: You can do the rendering inside the for-each if you want, because you've already got a reference to it, e.g.:
Most recent content node where value is not empty
Hoping someone can give my brain a jumpstart today.
Via XSLT, how do I get the node ID of a content item, where a property (photo) is not empty... sort the results by a date property and get the one, most recent node?
This looks like it might work but I'm not getting anything.
Hi Connie,
You need to do the position-test inside the loop (essentially after the sorting) and not when selecting the nodes to iterate (your for-each only iterates the first item), e.g.:
I'm guessing you need the ID to do the rendering - but just so you know: You can do the rendering inside the for-each if you want, because you've already got a reference to it, e.g.:
Hope that helps,
/Chriztian
Yeah, ended up with a bunch of nested loops but, hey it works. Not too bad since it's just hitting that one XML file.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.