Copied to clipboard

Flag this post as spam?

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


  • Thomas 212 posts 480 karma points c-trib
    Sep 20, 2017 @ 12:19
    Thomas
    0

    Leblender get Related links.

    Anyone that can help me with this.

    I'm trying to get all the links from a "Related links" picker with Leblender. I have this code right now, just to see the output.

    My View:

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    
    if (Model.Items.Any())
    {
        foreach (var item in Model.Items)
        {
            @item.GetValue("footerlink")
        }
    
    }
    

    The output I get is: but is a string?

    [  
       {  
          "caption":"facebook",
          "link":"http://facebook.dk",
          "newWindow":true,
          "edit":false,
          "isInternal":false,
          "type":"external",
          "title":"facebook"
       },
       {  
          "caption":"google",
          "link":"http://google.dk",
          "newWindow":false,
          "edit":false,
          "isInternal":false,
          "type":"external",
          "title":"google"
       }
    ]
    
  • Thomas 212 posts 480 karma points c-trib
    Sep 20, 2017 @ 12:38
    Thomas
    100

    Nevermind :) got it:

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    @using Umbraco.Web.Models
    
    @if (Model.Items.Any())
    
    {
    
    var multiUrlPicker = Model.Items.First().GetValue<RelatedLinks>("footerlink");
    if (Enumerable.Any(multiUrlPicker))
    {
            <ul>
                @foreach (var item in multiUrlPicker)
                {
                    var linkTarget = (item.NewWindow) ? "_blank" : null;
                    <li><a href="@item.Link" target="@linkTarget">@item.Caption</a></li>
                }
            </ul>
    }
    

    }

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies