What I'm trying to achieve, is that if one of the nav items is of a certain document type "ExternalLink" instead of linking the a href to the {umbraco.library:NiceUrl...} I'd like it to pull the link from a field i've added to the document type called "externalLinkAddress"
I believe i could so something like "data [@alias = 'externalLinkAddress']" for the link, i'm just not sure how to apply the "when" statement"
I moved the <xsl:choose> inside your <li></li> element so you only need to make the test for setting the active class once.
I also guess you by mistake have switched the two links around? You need to get the value from the externalLinkAdress when there is something in it, right?
Chriztian's code above worked perfectly, I was getting some errors with your code when I tried, not sure why? I appreciate your help regardless, I find it useful to see different ways to acheive a similar thing, always comes in handy somewhere down the line.
Old to New navigation when / otherwise situation
So i'm using one of the navigation templates for the New XSLT Schema, the code is as follows:
What I'm trying to achieve, is that if one of the nav items is of a certain document type "ExternalLink" instead of linking the a href to the {umbraco.library:NiceUrl...} I'd like it to pull the link from a field i've added to the document type called "externalLinkAddress"
I believe i could so something like "data [@alias = 'externalLinkAddress']" for the link, i'm just not sure how to apply the "when" statement"
Any help would be appreciated!
Thank you,
Amir
Hi Amir,
Try something like this:
/Chriztian
Hi Amir
If you're making use of the new schema the code in your second sample will not work since there is no data element in the umbraco.config file anymore.
Try this out and see if this works
<li>
<xsl:if test="@id = $currentPage/@id">
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="$ExternalLink">
<a class="navigation" href="externalLinkAddress">
<span><xsl:value-of select="@nodeName"/></span>
</a>
<xsl:otherwise>
<a class="navigation" href="{umbraco.library:NiceUrl(@id)}">
<span><xsl:value-of select="@nodeName"/></span>
</a>
</xsl:when>
</xsl:otherwise>
</xsl:choose>
</li>
A few comments
I moved the <xsl:choose> inside your <li></li> element so you only need to make the test for setting the active class once.
I also guess you by mistake have switched the two links around? You need to get the value from the externalLinkAdress when there is something in it, right?
Try it out and see if it works for you :-)
/Jan
Wow...was way to slow there :-)
/Jan
Hi Jan,
Chriztian's code above worked perfectly, I was getting some errors with your code when I tried, not sure why? I appreciate your help regardless, I find it useful to see different ways to acheive a similar thing, always comes in handy somewhere down the line.
Thanks!
Amir
is working on a reply...