I'm trying to make a condition, where the code only runs if a variable contains the currentPage.. I'm passing the $source page, to get all of its children... here's the code:
<xsl:variable
name="items"
select="umbraco.library:GetXmlNodeById($source)/descendant::* [@isDoc
and string(umbracoNaviHide) != '1']" />
<xsl:if test="contains($items, $currentPage)">
<xsl:for-each select="$items">
'do something'
</xsl:for-each>
</xsl:if>
If I choose the first page that is contained
in "$items", the code is triggered, but if I go to the 2nd or 3rd page
in $items, the code is not triggered
That's because contains() works on a string, so there's some complicated stuff happening that I can explain if you, like - but: You just need to test like this instead:
<xsl:if test="$items[@id = $currentPage/@id]">
<!-- do stuff -->
</xsl:test>
Check if variable contains "currentPage"
Hello guys,
I'm trying to make a condition, where the code only runs if a variable contains the currentPage..
I'm passing the $source page, to get all of its children...
here's the code:
<xsl:variable name="items" select="umbraco.library:GetXmlNodeById($source)/descendant::* [@isDoc and string(umbracoNaviHide) != '1']" />
<xsl:if test="contains($items, $currentPage)">
<xsl:for-each select="$items">
'do something'
</xsl:for-each>
</xsl:if>
If I choose the first page that is contained in "$items", the code is triggered, but if I go to the 2nd or 3rd page in $items, the code is not triggered
Hi Gonçalo,
That's because contains() works on a string, so there's some complicated stuff happening that I can explain if you, like - but: You just need to test like this instead:
Hope that helps,
/Chriztian
Bingo! That worked!
Thank you Chriztian!
is working on a reply...