I've added a textstring property "externalURL" to my Doctype. I want to enter in the external URL in the textstring and for that link to redirect to the external URL. However the following isn't working:
1. The property is not called externalUrl (XML is case sensitive - maybe it's externalURL?)
2. The property has (for some reason) not been published for the node in question (unlikely, but I've seen it happen)
3. The property contains one or more spaces/tabs - use normalize-space(externalUrl) instead of externalUrl != '' to make sure that's not the case
For navigations and similar structures you can really benefit from XSLT's template approach, e.g. - the following is another way to do what you're doing, but instead of repeating yourself at every level, there's a single template responsible for the link output:
<xsl:variablename="navRoot"select="$currentPage/ancestor-or-self::*[@level = $minLevel][not(self::OverviewSection)][not(umbracoNaviHide = 1 or hideFromSiteNavigation = 1)]"/>
<!-- These are the Document Types (aliases) to exclude from navigation --> <xsl:variablename="excludeDocTypes"select="'Chart | NewsItem | EmployeeTestimonial | JobDescription | PreviousCareerOpportunites'"/>
<xsl:templatematch="/"> <divclass="subnav"> <!-- Top level --> <xsl:apply-templatesselect="$navRoot"mode="link"/>
<!-- Template for all links --> <xsl:templatematch="*[@isDoc]"mode="link"> <!-- Grab any subpages --> <xsl:variablename="subPages"select="*[@isDoc][not(umbracoNaviHide = 1)][not(contains($excludeDocTypes, name()))][not(@template = 0)]"/>
<ahref="{umb:NiceUrl(@id)}"> <!-- Set CSS class if necessary --> <xsl:iftest="@id = $currentPage/@id"><xsl:attributename="class">current</xsl:attribute></xsl:if> <!-- Override href attribute if an external URL was set --> <xsl:iftest="normalize-space(externalUrl)"><xsl:attributename="href"><xsl:value-ofselect="externalUrl"/></xsl:attribute></xsl:if>
<xsl:value-ofselect="@nodeName"/> </a>
<!-- Any more levels to show? --> <xsl:iftest="$subPages and @level <= $maxLevel"> <ul> <xsl:apply-templatesselect="$subPages"mode="link"/> </ul> </xsl:if> </xsl:template>
Redirect to external URL
I've added a textstring property "externalURL" to my Doctype. I want to enter in the external URL in the textstring and for that link to redirect to the external URL. However the following isn't working:
Any suggestions?
Hi JV,
How does it not work?
What is rendered in the href attribute?
/Chriztian
If you do a:
on your page and view the source, can you find the "externalURL" property and does it have a value?
(first step, check it's definitely there!)
Cheers,
Drew
The "Current career opportunites" page should be redirecting to the "externalURL" however the result is as follows:
Here's my entire XSLT
Hi JV,
My top guesses as to what is wrong:
1. The property is not called externalUrl (XML is case sensitive - maybe it's externalURL?)
2. The property has (for some reason) not been published for the node in question (unlikely, but I've seen it happen)
3. The property contains one or more spaces/tabs - use normalize-space(externalUrl) instead of externalUrl != '' to make sure that's not the case
For navigations and similar structures you can really benefit from XSLT's template approach, e.g. - the following is another way to do what you're doing, but instead of repeating yourself at every level, there's a single template responsible for the link output:
/Chriztian
Thanks Chriztian, it was the case sensitive issue! I needed to change it to "externalURL".
Cheers!
is working on a reply...