Copied to clipboard

Flag this post as spam?

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


  • Mark Evans 86 posts 116 karma points
    Sep 19, 2014 @ 13:35
    Mark Evans
    0

    URL for content picker datatype

    can anyone tell me how i would render a url in a hyperlink for a page chosen via the content picker datatype?

  • Elliot Spaull 8 posts 55 karma points
    Sep 19, 2014 @ 14:00
    Elliot Spaull
    0

    Hi Mark!

    The content picker should just return the ID of the page you have picked, so you should just be able to do this:

    var page = Umbraco.Content(CurrentPage.linkPicker);
    

    Where 'linkPicker' is the name of your Content Picker property.

    And then you can access the Url like this:

    <a href="@page.Url">@page.Name</a>
    

    Hope this helps.

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 19, 2014 @ 14:26
    Jeavon Leopold
    2

    Hi Mark,

    @Umbraco.NiceUrl(CurrentPage.pickerPropertyAlias)
    

    Jeavon

  • Elliot Spaull 8 posts 55 karma points
    Sep 19, 2014 @ 14:36
    Elliot Spaull
    0

    Oh hey, that's a much simpler solution! :)

  • Mark Evans 86 posts 116 karma points
    Sep 19, 2014 @ 15:19
    Mark Evans
    0

    it sure is! 

     

    thanks a lot

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 19, 2014 @ 15:27
    Jeavon Leopold
    0

    You're welcome!

    If you only need the URL thats the way to do it. If you also need the Name then of course Elliot's suggestion is the answer as you have the whole object there.

Please Sign in or register to post replies

Write your reply to:

Draft