Copied to clipboard

Flag this post as spam?

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


  • Rich Green 2246 posts 4008 karma points
    Jan 09, 2010 @ 11:17
    Rich Green
    0

    NiceURL without .aspx?

    Hi,

    I need to grab the nice URL of a 'directory' of my site without the .aspx extension.

    So nodes are

    - Football Team

    - Charlton Athletic

    - Man Utd

    I need to grab them separately for reasons I won't go into. 

    <xsl:value-of select="umbraco.library:NiceUrl($sportID)" />
    <xsl:text>/</xsl:text>
    <xsl:value-of select="umbraco.library:NiceUrl($teamID)" />

    So above I'd like umbraco.library:NiceUrl($sportID) to return "Football-Team/Man-Utd.aspx"

    Thanks

    Rich

     

     

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Jan 09, 2010 @ 11:25
    Warren Buckley
    2

    Hey Rich a simple way to do remove the aspx for some of your links is as follows.

    By wrapping the niceURL call with a replace that finds the .aspx and replaces it with nothing.

    <xsl:value-of select="umbraco.library:Replace(umbraco.library:NiceUrl($sportID),'.aspx',''" />

    However looking at your logic you shouldn't need to build up the url or string like that, you should be able to use xPath to return that.

    You could just do this and it should already retrieve the full path of the url (which includes Football Team)

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

     

    I would be happy to help you with your XSLT or xPath if you explain exactly what you are trying to achieve.

    Warren :)

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 09, 2010 @ 11:36
    Douglas Robar
    3

    Why not just switch to extension-less urls in umbraco and never see the '.aspx' again? Anywhere?

    In the web.config file, just set:

    <add key="umbracoUseDirectoryUrls" value="true" />

    And then publish all the top-most nodes (and their children) to have umbraco re-calculate the urls.

    cheers,
    doug.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jan 09, 2010 @ 15:22
    Morten Bock
    1

    There is an attribute in the xml for a node that gives you the url name for it: @urlName. So for you "Man Utd" node you would get "man-utd" and nothing else.

  • Rich Green 2246 posts 4008 karma points
    Jan 09, 2010 @ 16:33
    Rich Green
    0

    Thanks, all great solutions!

  • Stefan Arngrimsson 36 posts 59 karma points
    Mar 02, 2010 @ 16:59
    Stefan Arngrimsson
    0

    Shouldn't the path end with a trailing slash? "/"

  • AntonioMX 58 posts 57 karma points
    Nov 20, 2010 @ 17:43
    AntonioMX
    0

    One question though, I  just changed my IIS7 configuration according to this and setting to true the umbracoUseDirectoryUrls key. The site has been up for over a year now and it has some well positioned keywords in the search engines, will this cause a negative effect on my rankings?

  • Craig100 1136 posts 2523 karma points c-trib
    Oct 15, 2011 @ 17:45
    Craig100
    0

    I just updated the web.config entry to:-

    <addkey="umbracoUseDirectoryUrls"value="true"/>

    and now find I've lost all the links to the stylesheets! How do you get around that? It was most unexpected. I'm developing on W7 with WebMatrix, so not a full IIS.

    Craig

     

  • Craig100 1136 posts 2523 karma points c-trib
    Oct 15, 2011 @ 17:48
    Craig100
    0

    Sorted it myself. I just needed a forward slash infront of the css. i.e. <link rel="stylesheet" href="/css/jquery-ui-1.8.16.custom.css">

    Hope this helps someone

    Craig

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Oct 15, 2011 @ 18:45
    Jan Skovgaard
    0

    Hi Craig

    This would probably have happened regardless that you made the switch to extensionless urls since you need to use absolute urls, to reference css, javascript etc. instead of relative urls.

    It has nothing to do with site using extensionless urls :-)

    /Jan

  • Craig100 1136 posts 2523 karma points c-trib
    Oct 15, 2011 @ 18:56
    Craig100
    0

    Interesting, it's been fine for the last 4 days and only changed as soon as I changed the web.config file. Maybe I was lucky. This is my first Umbraco site;)

    Craig

  • Proxicode 127 posts 323 karma points
    Jan 10, 2013 @ 02:10
    Proxicode
    0

    Thanks Douglas!  This did the trick for me.  

    <addkey="umbracoUseDirectoryUrls"value="true"/> 
    Incidently it had to be at the end of the appsettings for some reason, but it worked as you said.

    I'd like to upvote your response but don't have the karma yet.  Thanks

Please Sign in or register to post replies

Write your reply to:

Draft