Copied to clipboard

Flag this post as spam?

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


  • anvimi 17 posts 20 karma points
    Jun 02, 2009 @ 12:21
    anvimi
    0

    NiceUrl problem

    Can anybody tell me what's wrong with this:

    [code]
    [/code]

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 02, 2009 @ 12:40
    Dirk De Grave
    0

    Hi,

    Maybe you should tell what's wrong.
    Syntax is ok, just not sure what you're trying to achieve.
    I'm quite sure you won't find a node with id = 1, so output of this xslt snipped will be blank!

    If you wish to receive an answer, give us some more info on:

    -Context (where would you like to use this)
    -Purpose (why do you want to have nice url for node with id = 1...)

    Looking forward to your answers!

    Cheers,
    /Dirk

  • anvimi 17 posts 20 karma points
    Jun 02, 2009 @ 13:09
    anvimi
    0

    Hi Dirk,

    I need to call NiceUrl with a parameter passed to my macro. If I write simply [code][/code] it's OK,
    but if I try [code][/code] I see a red rectangle with stack trace.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 02, 2009 @ 13:42
    Dirk De Grave
    1

    Hi,

    allright, get the point now.
    must surround the

    [code]
    [/code]

    with an xslt:if statement

    [code][/code]

    (Reason: the parameters passed in don't have a value until runtime, and calling NiceUrl with a number that gets converted from an empty string results in an OverflowException, which is probably the exception message you've received in the 'red rectangle')

    Hope this helps.

    Regards,
    /Dirk

  • anvimi 17 posts 20 karma points
    Jun 02, 2009 @ 14:14
    anvimi
    0

    Yes, that was it! You saved my day, thank you =d>

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 02, 2009 @ 23:21
    Jan Skovgaard
    0

    I reckon Dirk's solution as the best one but you could also just have checked the "skip error testing" box :)

    But then you would have to remember to do that every time you make modifications to the xslt of course. And it could be hard to discover actual errors that has nothing to do with the nirceUrl. But I just thought you should know about the possibility to skip error testing since it can sometimes be usefull during development.

  • Jay Walker 10 posts 38 karma points
    Sep 23, 2009 @ 08:36
    Jay Walker
    0

    In umbraco version 4.0.2.1 you have to use the hack for

    umbraco.library:NiceUrl(int id)

    but it is not required for

    umbraco.library:GetXmlNodeById(string id)

    Both expect a parameter that should be a number. GetXmlNodeById doesn't require a test on the parameter before calling.

    I'd like to see NiceUrl take a string parameter to avoid the extra check but I don't know what side effects this might have.

Please Sign in or register to post replies

Write your reply to:

Draft