Copied to clipboard

Flag this post as spam?

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


  • Morten K. J. 23 posts 64 karma points
    Mar 22, 2010 @ 17:06
    Morten K. J.
    0

    Create NiceUrl with alttemplate

    I need to be able to create a NiceUrl including an alttemplate. It is easy to create the nice url using umbraco.library:NiceUrl, but how can I add an alttemplate to this url?

    For instance I would like to create an url to 'profile.aspx' with the alttemplate 'simple' making the complete url look like this: profile/simple.aspx - and not like profile.aspx?alttemplate=simple.

    I have version 4.0.3 installed

  • dandrayne 1138 posts 2262 karma points
    Mar 22, 2010 @ 17:23
    dandrayne
    1

    Hi Morten

    This is a bit hacky and untested but it may work.  Instead of calling niceurl youi could create a template to call which will do a replace on your url

    <xsl:template name="templateUrl">
    <xsl:param name="nodeId" />
    <xsl:variable name="niceUrl" select="umbraco.library:NiceUrl($nodeId)" />
    <xsl:value-of select="umbraco.library:Replace($niceUrl, '.aspx', '/templateName.aspx')" />
    </xsl:template>

    Then instead of

    <xsl:value-of select="umbraco.library:NiceUrl(current()/@id)" />

    you'd use

    <xsl:call-template name="templateUrl">
    <xsl:with param name="nodeId" select="current()/@id" />
    </xsl:call-template>

    Worth a shot!

    Dan

     

  • Morten K. J. 23 posts 64 karma points
    Mar 24, 2010 @ 15:02
    Morten K. J.
    0

    Hi Dan.

    It is hacky, but it works - at least when I enter the missing dash in "with-param" ;)

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft