Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sergio 4 posts 24 karma points
    Aug 19, 2012 @ 18:21
    Sergio
    0

    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

     

  • Sergio 4 posts 24 karma points
    Aug 19, 2012 @ 18:25
    Sergio
    0

    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,

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 19, 2012 @ 19:06
    Fuji Kusaka
    0

    Hi Sergion,

    Change your value to

    <xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/> 

    This should get you to the first node url "/"

    //fuji

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Aug 19, 2012 @ 19:25
    Bo Damgaard Mortensen
    0

    @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.

  • Sergio 4 posts 24 karma points
    Aug 20, 2012 @ 10:25
    Sergio
    0

    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 #

  • Sergio 4 posts 24 karma points
    Aug 20, 2012 @ 22:14
    Sergio
    0

    Still not working, Any other ideas????

     

    Thanks

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 20, 2012 @ 22:35
    Chriztian Steinmeier
    2

    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:

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />

    So to get the URL of that, you would do:

    <a href="{umbraco.library:NiceUrl($siteRoot/@id)}">
        <xsl:value-of select="$siteRoot/@nodeName" />
    </a>

    (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:

    <a href="/myhome.aspx">My Home</a>

    - which is why I usually hardcode the URL to "/" whenever I need that particular link...

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft