@Sergio: Can you please try and Publish (hit Save and Publish) the root node and run your code again? A node that doesn't exist in the XML cache gets the hashtag as it's URL :-)
@Fuji: I think that XSLT snippet gets get nice url of the current page :-) Segio want's the url of the site root node.
Problem getting the URL of the homepage
Hi there,
I'm trying to get the URL of the homepage of the site to use it in a link. This is the code I'm using:
<a>
<xsl:attribute name="href">
<!--<xsl:value-of select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::root//@id)" />-->
</xsl:attribute>
<xsl:value-of select="$currentPage/ancestor-or-self::root//@nodeName" />
</a>
The result I get for the href is '#' instead of a '/'
Can anyone help?
Thanks
Please, ignore the comment tags, the code is:
<a>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::root//@id)" />
</xsl:attribute>
<xsl:value-of select="$currentPage/ancestor-or-self::root//@nodeName" />
</a>
Thanks again,
Hi Sergion,
Change your value to
This should get you to the first node url "/"
//fuji
@Sergio: Can you please try and Publish (hit Save and Publish) the root node and run your code again? A node that doesn't exist in the XML cache gets the hashtag as it's URL :-)
@Fuji: I think that XSLT snippet gets get nice url of the current page :-) Segio want's the url of the site root node.
Hi,
Thanks for your replies.
@Fuji: I tried that code before posting but as Bo says it gets the Url of the current page when I want the root page
@Bo: I republished the entire site and all the individual pages but no luck so far :( still getting #
Still not working, Any other ideas????
Thanks
Hi Sergio,
I usually create a siteRoot variable just after the currentPage param, so it's easy (and readable) to get to the home page:
So to get the URL of that, you would do:
(Note the use of curly-braces to grab a value inside an attribute)
But - as it turns out, you will *not* get the "/" URL that you're expecting, but rather something like this:
- which is why I usually hardcode the URL to "/" whenever I need that particular link...
/Chriztian
is working on a reply...