Umbraco/Samples and Articles/Templates/URLsubstitution

< Umbraco < Samples and Articles < Templates

What is it?

Umbraco URL's look like this:
'http://www.mysite.org/subpage1/subpage1-1/somedocument1.aspx'
You can make it to look like:
'http://www.mysite.org/somedocument1.aspx'
or even
'http://www.mysite.org/somedocument'

Reasons

The document name field by default is converted to an URL. If you have a document named "Странитса", it will be converted to an unacceptable link for www and the structure of your site will be broken.

Solution

Add a new property with an alias umbracoUrlAlias, the property name is important. *incomplete - what sort of property (i.e.: label, tags, textstring)?*

When substituting url's for several nodes, maybe even in full branch, you must type full ascending path, otherwise links will be broken.
Example: If you have the first subnode named Frontpage with UrlAlias Pagefront and its child Products with UrlAlias Items, type in Products page alias field:

Pagefront/Items (do not add .aspx)

Additional hints

When you replaced the url to get new and working links and you use XSLT transformations for generating a site navigation or sitemap, modifications are needed in XSLT file. Look at the following sample how this could be done:

<xsl:choose>
  <xsl:when test="data [@alias = 'umbracoUrlAlias'] != ''">
    <a href="{concat('/', data [@alias = 'umbracoUrlAlias'],'.aspx')}"><xsl:value-of
    select="@nodeName"/></a>
  </xsl:when>
  <xsl:otherwise>
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of
    select="@nodeName"/></a>
  </xsl:otherwise>
</xsl:choose>	


WILL CONTINUE ASAP

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.