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
This XSLT thing is biting me everytime I even point at it. :(
I want to define on the top node some Related Links, that need to appear on every page on the site.
So, I found this post: our.umbraco.org/.../3331-Related-Links-Recursive
But for some reason, it does not list the links, I added in the related links property on the top node (alias='servicesLinks')
<xsl:template match="/"> <h2>Services</h2> <!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/ancestor-or-self::node [count(data[@alias='servicesLinks']/links/link)> 0] [1] /data[@alias='servicesLinks']/links/link"> <li> <xsl:element name="a"> <xsl:if test="./@newwindow = '1'"> <xsl:attribute name="target">_blank</xsl:attribute> </xsl:if> <xsl:choose> <xsl:when test="./@type = 'external'"> <xsl:attribute name="href"> <xsl:value-of select="./@link"/> </xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/> </xsl:attribute> </xsl:otherwise> </xsl:choose> <xsl:value-of select="./@title"/> </xsl:element> </li> </xsl:for-each> </ul> <!-- Live Editing support for related links. --> <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" /> </xsl:template>
Any ideas?
Try replacing "./@newwindow" with "@newwindow" and the same for all similar declarations.
Why are you accessing the '0' index of the node list? should this not always only return one item. Try removing [0] and see what the output is.
Failing both of these, can you post the output of
<textarea cols="30" rows="30"> <xsl:copy-of select="$currentPage/ancestor-or-self::node[count(data[@alias='servicesLinks']/links/link)> 0] [1]/data[@alias='servicesLinks']/links/link" /></textarea>
delete
<!-- Live Editing support for related links. --> <xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />
Thanks for the help guys.
This is the code that worked for me.
<xsl:template match="/"> <h2>Services</h2> <!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/ancestor-or-self::node [count(data[@alias='servicesLinks']/links/link)> 0] /data[@alias='servicesLinks']/links/link"> <li> <xsl:element name="a"> <xsl:if test="@newwindow = '1'"> <xsl:attribute name="target">_blank</xsl:attribute> </xsl:if> <xsl:choose> <xsl:when test="@type = 'external'"> <xsl:attribute name="href"> <xsl:value-of select="@link"/> </xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(@link)"/> </xsl:attribute> </xsl:otherwise> </xsl:choose> <xsl:value-of select="@title"/> </xsl:element> </li> </xsl:for-each> </ul> </xsl:template>
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.
Continue discussion
Related Links recursive ... how to get this to work?
This XSLT thing is biting me everytime I even point at it. :(
I want to define on the top node some Related Links, that need to appear on every page on the site.
So, I found this post: our.umbraco.org/.../3331-Related-Links-Recursive
But for some reason, it does not list the links, I added in the related links property on the top node (alias='servicesLinks')
<xsl:template match="/">
<h2>Services</h2>
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/ancestor-or-self::node [count(data[@alias='servicesLinks']/links/link)> 0] [1] /data[@alias='servicesLinks']/links/link">
<li>
<xsl:element name="a">
<xsl:if test="./@newwindow = '1'">
<xsl:attribute name="target">_blank</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="./@type = 'external'">
<xsl:attribute name="href">
<xsl:value-of select="./@link"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="./@title"/>
</xsl:element>
</li>
</xsl:for-each>
</ul>
<!-- Live Editing support for related links. -->
<xsl:value-of select="umbraco.library:Item($currentPage/@id,$propertyAlias,'')" />
</xsl:template>
Any ideas?
Try replacing "./@newwindow" with "@newwindow" and the same for all similar declarations.
Why are you accessing the '0' index of the node list? should this not always only return one item. Try removing [0] and see what the output is.
Failing both of these, can you post the output of
delete
Thanks for the help guys.
This is the code that worked for me.
<xsl:template match="/">
<h2>Services</h2>
<!-- The fun starts here -->
<ul>
<xsl:for-each select="$currentPage/ancestor-or-self::node [count(data[@alias='servicesLinks']/links/link)> 0] /data[@alias='servicesLinks']/links/link">
<li>
<xsl:element name="a">
<xsl:if test="@newwindow = '1'">
<xsl:attribute name="target">_blank</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="@type = 'external'">
<xsl:attribute name="href">
<xsl:value-of select="@link"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl(@link)"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@title"/>
</xsl:element>
</li>
</xsl:for-each>
</ul>
</xsl:template>
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.