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 25, 2015 @ 00:50
    Chad
    0

    Using a Multinode Treepicker within LeBlender

    Hello,

    I have a document type where have multiple properties (itemIcon, itemTitle, itemOverview, etc...) within it. I would like these "widgets" to be able to be used within the grid 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 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:23
    Chad
    101

    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:

    @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>
          }
        }
      }
    }
    
  • Heather Floyd 610 posts 1032 karma points MVP 6x c-trib
    Sep 22, 2015 @ 17:59
    Heather Floyd
    0

    I found that this also works when dealing with MNTPs which have been added as properties to a LeBlender Grid Editor:

    var picker = item.GetValue<Int32[]>("GridPropertyAliasForMntp");
    
    if (picker.Any())
    {
        var pickedNodes = Umbraco.TypedContent(picker);
    
        if (pickedNodes != null)
        {
            foreach (var node in pickedNodes)
            {
                <p>@node.Name</p>
            }
        }
    }
    
  • Kunal 19 posts 116 karma points
    Mar 03, 2019 @ 01:03
    Kunal
    0

    In v7.10 this works

    Udi[] pickedNodes= item.GetValue<Udi[]>("GridPropertyAliasForMntp");
    
    if (pickedNodes.Any())
    {
            foreach (var node in pickedNodes)
            {
                var pubContent = Umbraco.TypedContent(node);
                <p>@pubContent.Name</p>
            }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft