Copied to clipboard

Flag this post as spam?

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


  • Gísli Freyr Svavarsson 43 posts 126 karma points
    Oct 31, 2012 @ 15:42
    Gísli Freyr Svavarsson
    0

    Can't get NiceUrl to work

    hi, i'm trying to set NiceUrl to a link I have but the answeres i've found on here and google don't seem to work. here's my code can anybody point it out to my why it doesn't work: 

    <a href="@item.destinationUrl.NiceUrl">@item.Name</a>

    i've also tried different versions such as: 

    <a href="@umbraco.library.NiceUrl(@item.destinationUrl)">@item.Name</a>

     

    amongts other. any takers?

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 31, 2012 @ 16:28
    Tom Fulton
    1

    Hi,

    Normally you don't need to use NiceUrl in Razor, you can just use the .Url property of your dynamic node.  Ex:  @item.Url

    But in your case I'm guessing you want to get the URL of a content picked with a content picker?  In that case I would do something like this:

    var destination = Library.NodeById(item.destinationUrl);
    <a href="@destination.Url">@destination.Name</a>

    Hope this helps,
    Tom 

  • Gísli Freyr Svavarsson 43 posts 126 karma points
    Oct 31, 2012 @ 16:48
    Gísli Freyr Svavarsson
    0

    Thanks Tom that worked. had to work around it a bit but still worked. thanks.

Please Sign in or register to post replies

Write your reply to:

Draft