Copied to clipboard

Flag this post as spam?

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


  • Kate 267 posts 610 karma points
    Feb 28, 2016 @ 12:28
    Kate
    0

    link Picker output

    Hi

    On my frontpage I am using this Link Picker https://our.umbraco.org/projects/backoffice-extensions/link-picker/ and it works fin. My problem is that on my frontpage the user can insert a external link and I would like to use that link on at subpage. But I cant seem to get the right output. In my PartialViewMacroPage I have tried this:

        @{
                var brandLink1 = Model.Content.AncestorOrSelf(1).GetPropertyValue("brandLink1");
        }
    <p>@brandLink1</p>
    

    But the output is this:

    { "id": 0, "name": "", "url": "http://centurion.dk/", "target": "_self" }
    

    and I would like it to be just: http://centurion.dk/

    It's probably the GetPropertyValue that is wrong, but I dont know what to put insted :-)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 28, 2016 @ 16:10
    Jan Skovgaard
    0

    Hi Kate

    At a first glance I'm wodnering if you have you tried to simply just write @brandLink1.url - Does that work?

    /Jan

  • Kate 267 posts 610 karma points
    Feb 28, 2016 @ 16:40
    Kate
    0

    That gives me an error. It's becaurse I'm getting the link-input from my frontpage and not from the pages that I'm currently at. Does that make any sense?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 28, 2016 @ 17:36
    Jan Skovgaard
    0

    Hi Kate

    Just had a go with the package myself. I think some propertyvalueconverters are missing in order to make it possible for your to use it strongly typed.

    Dynamically it works by writing @CurrentPage.links.url - Which in your case should be @CurrentPage.brandLink1.url

    /Jan

  • Kate 267 posts 610 karma points
    Feb 28, 2016 @ 17:43
    Kate
    0

    The problem is that I cant use CurrentPage, because the link-information comes from another template(frontpage) and I want to use the link that the user insertet on a subpage.

    That's why I thought, that if I used this code I would get the information from my frontpage

        @{
    var brandLink1 = Model.Content.AncestorOrSelf(1).GetPropertyValue("brandLink1");
            }
    
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 28, 2016 @ 18:02
    Jan Skovgaard
    0

    Hi Kate

    Ah yes, sorry about that - But you can actually use CurrentPage to fetch it from a subpage as well.

    You just need to write it like this @CurrentPage.AncestorOrSelf(1).brandLink1.url

    Hope this helps.

    /Jan

  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Feb 28, 2016 @ 18:04
    Søren Kottal
    102

    Try

    @{
    var brandLink1 = Model.Content.AncestorOrSelf(1).GetPropertyValue<dynamic>("brandLink1");
    }
    
    @brandLink1.url
    
  • Kate 267 posts 610 karma points
    Feb 28, 2016 @ 18:18
    Kate
    0

    Jan: Sorry, it still doesen't work

    Søren: it works :-). Thanks. I'm really grateful

    Do you know where I can read more about this

  • Søren Kottal 712 posts 4570 karma points MVP 6x c-trib
    Feb 28, 2016 @ 18:25
Please Sign in or register to post replies

Write your reply to:

Draft