Ahh yeah, of course, didn't think of that. Maybe you should change the for-each as well:
<xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1' and string(hightlight)='1']">
Then the for-each should only run through the nodes which has the highlight property set to 1. And then you can use the position()=1 inside the for-each.
How do I solve this if I can't break a for-each loop
<xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:if test="highlight = 1">
<xsl:variable name="mediaId" select="number(./image)" />
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:value-of select="$mediaNode/umbracoFile"/>
</xsl:if>
</xsl:for-each>
I want this loop to just include the first hit on highlight = 1
If it hits two times the output may look like this:
/media/68/ingen_bild.jpg/media/171/a113_tvattmedel.jpg
which is useless as an image source. I know I cant break a for-each in xslt...so how should I approach this problem?
/Fredrik
Hi Fredrik
You should be able to use the position() in xslt to solve your problem like this:
You can place it outside the other if-statement you've got, or probably just merge the two of them together with an 'and' :)
/Kim A
The problem with position is that it depends on the node that is first hit byt the if statement.
Therefore position()='1' wont work...it can be anything 4, 12, 3.
What do you mean by merging them together with an and, how would that solve the problem?
Ahh yeah, of course, didn't think of that. Maybe you should change the for-each as well:
<xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1' and string(hightlight)='1']">
Then the for-each should only run through the nodes which has the highlight property set to 1. And then you can use the position()=1 inside the for-each.
Does that work?
/Kim A
Works like a charm!
is working on a reply...