Copied to clipboard

Flag this post as spam?

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


  • karen 186 posts 461 karma points
    Jan 26, 2010 @ 23:22
    karen
    0

    NiceUrl and umbracoUrlAlias

    I am generating a menu using my content tree.

    However the content tree contains some grouping folders that I don't want in the url, so I added the use of 'umbracoUrlAlias'.

    However, I am not sure what to use in my menu xslt to get the umbracoUrlAlias and get the correct URL.

    Tried:

    <a href="{umbraco.library:NiceUrl(@id)}">    Gives me the full node path, with the grouping folders I don't want in the URL

    <a href="{data[@alias='umbracoUrlAlias']}">  Still gives me the grouping folders in the URL, but removes the .aspx from the end

    Example:

    /folderA/Somepage.aspx, I have umbracoUrlAlias = 'Somepage', I want the url generated in my xslt to be /somepage.aspx

    Thanks

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jan 27, 2010 @ 00:17
    Chriztian Steinmeier
    0

    Hi Karen,

    You're on the right track, but you have to manually build the URLs using umbracoUrlAlias - the property hooks the alias up so Umbraco will take you to the right page, but NiceUrl() will always build the "standard" URL (from what I've tested).

    You can use this snippet to generate your links:

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

    /Chriztian

  • karen 186 posts 461 karma points
    Jan 27, 2010 @ 01:05
    karen
    0

    Thanks very much!

Please Sign in or register to post replies

Write your reply to:

Draft