Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1282 posts 2739 karma points
    Apr 21, 2015 @ 21:53
    Amir Khan
    0

    List children of page chosen

    Hi! I'm trying to build a content picker where I pick the top level of content and list its children version.

    I'm seeming to get stuck when trying to access the children of a blender model, or any of the typically returned Umbraco properties. Is it possible to just get a node chosen with a leblender content picker and iterate through its children?

    Here's what I'm trying now, which is returning 'char' does not contain a definition for 'Id'.

    Thank you!
    Amir

     

    @inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.BlenderModel>


    @{
    var multiUrlPicker = Model.Items.First().GetValue<dynamic>("choosePage");
    if (Enumerable.Any(multiUrlPicker))
    {
    <ul>
    @foreach (var item in multiUrlPicker)
    {
    <li>@item.Id</li>
    }
    </ul>
    }
    }
  • Antoine 176 posts 1494 karma points
    May 03, 2015 @ 11:03
    Antoine
    101

    A Content Picker datatype return an id, not a IPublishedContent. So, you have first to lost you IPublishedContent:

    @{
        var choosePage = Model.Items.First().GetValue<dynamic>("choosePage");
        if (choosePage != null)
        {
            IPublishedContent content = Umbraco.TypedContent(choosePage);
            <ul>
                @foreach (var item in content.Children())
                {
                    <li>@item.Id</li>
                }
            </ul>
        }
    }

    Does it make sense?

  • Amir Khan 1282 posts 2739 karma points
    May 15, 2015 @ 22:07
    Amir Khan
    0

    Yes! Thank you Antoine.

    -Amir

Please Sign in or register to post replies

Write your reply to:

Draft