Copied to clipboard

Flag this post as spam?

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


  • Chad 25 posts 196 karma points
    Aug 27, 2015 @ 15:13
    Chad
    0

    Multinode treepicker in a LeBlender editor

    Hello,

    I have a document type where have multiple properties (itemIcon, itemTitle, itemOverview, etc...) within it. I need to have these "widgets" be able to be used within the Umbraco grid using LeBlender, used across different pages in the site - think sidebar promos, pre-footer promos, and so forth.

    I've created a data type of "Feature Box" which uses the multinode treepicker, and then in the Grid Editor/LeBlender Editor I've added a property of "Feature Selector" that uses my feature box as the data type.

    All is good where I can select the node that I want to load content from, but where I'm stuck now is how do I actually render those properties (the itemIcon, itemTitle, etc) within the view for the Feature Selector?

    I've been searching examples on how to render content from the treepicker but I can't get anything to work when it's within LeBlender. I've tried going with @item.GetValue("itemTitle") and var itemTitle = Model.Items.First().GetValue<dynamic>("itemTitle"); <p>@itemTitle</p> with no success.

    Could anyone please help point me in the right direction?

    Thanks!

  • Chad 25 posts 196 karma points
    Sep 09, 2015 @ 04:27
    Chad
    100

    I was able to figure this out after a lot of research combined with trial and error. Here is how I was able to get the properties from the content/document type, I hope it helps if anyone else runs in to this!

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    
    @{
      var item = Model.Items.ElementAt(0);
      var boxPicker = item.GetValue<string>("featureBoxPicker");
    
      if (!string.IsNullOrWhiteSpace(boxPicker))
      {
        var boxList = boxPicker.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
        var calloutBox = Umbraco.TypedContent(boxList);
    
        if (calloutBox != null)
        {    
          foreach (var piece in calloutBox)
          {
            var itemLink = piece.GetPropertyValue<dynamic>("itemLink");
    
            <div class="feature-box" style="background-image: url(@Umbraco.TypedMedia(piece.GetPropertyValue<string>("itemBgImg")).Url);">
              <div class="details">
                <i class="@piece.GetPropertyValue("itemIcon")"></i>
                <h3>@piece.GetPropertyValue("itemTitle")</h3>
                <p>@piece.GetPropertyValue("itemOverview")</p>
                <p><a href="@itemLink.url" target="@itemLink.target">Learn More</a></p>
              </div>
            </div>
          }
        }
      }
    }
    
  • 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