Copied to clipboard

Flag this post as spam?

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


  • Thomas 319 posts 606 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 319 posts 606 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>
    }
    

    }

Please Sign in or register to post replies

Write your reply to:

Draft