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
HI all,
I'm in a situation where I have to compare a node name in one collection of nodes to a document property type of another set of nodes.
In pseudo: node/document type property value = NodeInOtherCollection/nodeName { expose data from first node }
Don't know if that makes any sense? This is the xslt I have now:
<xsl:template match="/"> <xsl:variable name="categories" select="$currentPage/ancestor-or-self::*/* [@level=2]/* [@isDoc and string(umbracoNaviHide) != 1]" /> <xsl:variable name="docs" select="$currentPage/ancestor-or-self::*//DocAlias [@isDoc and string(umbracoNaviHide) != 1]" /> <!-- start writing XSLT --> <ul> <xsl:for-each select="$categories"> <xsl:for-each select="$docs"> <xsl:if test="current()/@nodeName = $docs/memberType"> <li><xsl:value-of select="current()/@nodeName" /></li> </xsl:if> </xsl:for-each> </xsl:for-each> </ul> </xsl:template>
I honestly don't know what to put in the if statement and the value-of select=""
Does anyone know how to do this? :)
Thanks in advance!
Should note that I have tested the output of the two variables and the output is right :)
Figured it out myself ;)
Didn't need a nested loop to do what I wanted. This was all it took:
<xsl:template match="/"> <xsl:variable name="categories" select="$currentPage/ancestor-or-self::*/* [@level=2]/* [@isDoc and string(umbracoNaviHide) != 1]" /> <xsl:variable name="docs" select="$currentPage/ancestor-or-self::*//DocAlias [@isDoc and string(umbracoNaviHide) != 1]" /> <!-- start writing XSLT --> <ul> <xsl:for-each select="$docs"> <xsl:if test="current()/partnerType = $categories/@nodeName"> <li><xsl:value-of select="current()/bodyText" /></li> </xsl:if> </xsl:for-each> </ul> </xsl:template>
Found myself needing to something like this on occasion thats quite an elegant way of doing it i must say.
Glad you could use it, Colin! :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Loop through two collections
HI all,
I'm in a situation where I have to compare a node name in one collection of nodes to a document property type of another set of nodes.
In pseudo: node/document type property value = NodeInOtherCollection/nodeName { expose data from first node }
Don't know if that makes any sense? This is the xslt I have now:
<xsl:template match="/">
<xsl:variable name="categories" select="$currentPage/ancestor-or-self::*/* [@level=2]/* [@isDoc and string(umbracoNaviHide) != 1]" />
<xsl:variable name="docs" select="$currentPage/ancestor-or-self::*//DocAlias [@isDoc and string(umbracoNaviHide) != 1]" />
<!-- start writing XSLT -->
<ul>
<xsl:for-each select="$categories">
<xsl:for-each select="$docs">
<xsl:if test="current()/@nodeName = $docs/memberType">
<li><xsl:value-of select="current()/@nodeName" /></li>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</ul>
</xsl:template>
I honestly don't know what to put in the if statement and the value-of select=""
Does anyone know how to do this? :)
Thanks in advance!
Should note that I have tested the output of the two variables and the output is right :)
Figured it out myself ;)
Didn't need a nested loop to do what I wanted. This was all it took:
<xsl:template match="/">
<xsl:variable name="categories" select="$currentPage/ancestor-or-self::*/* [@level=2]/* [@isDoc and string(umbracoNaviHide) != 1]" />
<xsl:variable name="docs" select="$currentPage/ancestor-or-self::*//DocAlias [@isDoc and string(umbracoNaviHide) != 1]" />
<!-- start writing XSLT -->
<ul>
<xsl:for-each select="$docs">
<xsl:if test="current()/partnerType = $categories/@nodeName">
<li><xsl:value-of select="current()/bodyText" /></li>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:template>
Found myself needing to something like this on occasion thats quite an elegant way of doing it i must say.
Glad you could use it, Colin! :)
is working on a reply...