I'm hooking a Umbraco build up to a XML feed of properties and I currently have a "read more" link which points to a page like /indepth.aspx?id=1234 and using umbraco.library:Request("id") to get the id. No problem except its not very user/search engine friendly.
How can I make "sexy" urls in Umbraco that contain data? Something like:
Umbraco ships with a url rewriting module called UrlRewriting.net so you can edit your UrlRewriting.config to your requirements. For documentation see http://urlrewriting.net
Awesome response, thanks guys. Already got it working. Next problem though is how to make the urls SEO friendly similar to NiceUrl but without a node id?
Built up some simple templates which do some swapping of characters and happy to go that route but wondering if there is anything already out there?
Dynamic Urls with data in them?
I'm hooking a Umbraco build up to a XML feed of properties and I currently have a "read more" link which points to a page like /indepth.aspx?id=1234 and using umbraco.library:Request("id") to get the id. No problem except its not very user/search engine friendly.
How can I make "sexy" urls in Umbraco that contain data? Something like:
/property/indepth/street-name/town/1234
Any ideas?
Hi,
You could use the built-in URL-rewriter.
This is one tutorial: http://www.christophertl.net/1513.aspx
/Fredrik
Umbraco ships with a url rewriting module called UrlRewriting.net so you can edit your UrlRewriting.config to your requirements. For documentation see http://urlrewriting.net
Yep, UrlRewriting is the way to go... quick example:
Cheers, Lee.
Awesome response, thanks guys. Already got it working. Next problem though is how to make the urls SEO friendly similar to NiceUrl but without a node id?
Built up some simple templates which do some swapping of characters and happy to go that route but wondering if there is anything already out there?
Quick example. I want to convert this:
Flat 4 - Some street or other, Huddersfield
to
/flat-4-some-street-or-other/huddersfield/
I'm using this at the minute which works but leaves double "--" in the url :(
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:template name="Helpers.toLowerCase"><xsl:param name="input" select="''" /><xsl:value-of select="translate( $input, $uppercase, $lowercase )" /></xsl:template>
<xsl:template name="Helpers.toSEOFriendly">
<xsl:param name="input" select="''" />
<xsl:variable name="dodgyChars" select="' ,.#_-'" />
<xsl:variable name="replacementChar" select="'-----'" />
<xsl:variable name="lowercased"><xsl:call-template name="Helpers.toLowerCase"><xsl:with-param name="input" select="$input" /></xsl:call-template></xsl:variable>
<xsl:variable name="escaped"><xsl:value-of select="translate( $lowercased, $dodgyChars, $replacementChar )" /></xsl:variable>
<xsl:value-of select="$escaped" />
</xsl:template>
<xsl:template match="/">
Url: <xsl:call-template name="Helpers.toSEOFriendly"><xsl:with-param name="input" select="num" /></xsl:call-template>
</xsl:template>
Hi Peter,
You could write an XSLT extension to use built-in Umbraco methods?
e.g. To remove/replace unwanted characters, use:
This method loops through each of the chars from "requestHandler/urlReplacing" in "umbracoSettings.config".
But if you want to keep it all in XSLT, then using the "translate()" function should be suffice.
Cheers, Lee.
is working on a reply...