Copied to clipboard

Flag this post as spam?

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


  • Connie DeCinko 931 posts 1160 karma points
    Mar 29, 2011 @ 22:15
    Connie DeCinko
    0

    Get URL extension in XSLT

    I want to set a variable in my XSLT file based upon which server the code is running on.  Is there a way to look at and get the last three characters or the domain name?  For example in psuedo code:

    If server is www.abc.com then variable equals "com", else if server is www.abc.stg then variable equals "stg", else if server is www.abc.dev then variable equals "dev".

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 29, 2011 @ 22:36
    Jan Skovgaard
    1

    Hi Connie

    Is this what you're after?

      <xsl:variable name="url" select="substring-after(umbraco.library:RequestServerVariables('URL),'.')"/>
     <xsl:variable name="domain" select="substring-after($url,'.')" />

    <xsl:value-of select="$domain" />

    /Jan

  • jivan thapa 194 posts 681 karma points
    Mar 29, 2011 @ 22:36
    jivan thapa
    1

    HI, connie Decinko.

    I did same job for  business company websites. I can't release code. But I will give some hints that may help you.

    I did for global footer, Global footer link should generate dynamically. for example. www.abc.dev, www.abc.staging or www.abc.production

    .. I add custom attributes and value in web.config file.

    <custom value ="dev" />web.config for development server

    <custom value="staging" /> web.config for Staging server

    In my content page. i just save "abc" without "www" and ".com" or other extensions.

    I use c# to read custom value from web.config and append on the fly.

    example :

    Public string GetUrl( string shortName)

    {

    string environment = " this value should be read from web.config file."; // in my case i will read from <custom value="staging" /> so value will be staging

    return "http://www" + shortName + "envoronment ";

    }

    .......... hope it will help you

     

  • Connie DeCinko 931 posts 1160 karma points
    Mar 29, 2011 @ 22:46
    Connie DeCinko
    0

    Jeevan, I see where you are going with this as it is similar to one of the packages.  However, I went with a variation of Jan's idea which seems to work just fine (using in my main menu).

    <xsl:variable name="server_name" select="substring-after(umbraco.library:RequestServerVariables('SERVER_NAME'),'.')"/>
    <xsl:variable name="server" select="substring-after($server_name,'.')" />
Please Sign in or register to post replies

Write your reply to:

Draft