Copied to clipboard

Flag this post as spam?

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


  • Darren Wilson 238 posts 646 karma points
    Mar 20, 2019 @ 23:55
    Darren Wilson
    0

    Nested content - fetch Content Picker

    Hi Folks,

    I've got a nested content (products) data type which has a standard content picker (productPicker) which I want to fetch the URL I'm having some issues with fetching the content picker content - it throws a Null even tho I have content. Any ideas what I've done wrong? It's the second foreach that's throwing the error.

    Thanks. Darren

    @{
    var items = Model.Value<IEnumerable<IPublishedElement>>("products");
    
    foreach (var item in items)
    {
    
            foreach (var item2 in item.Value<IEnumerable<IPublishedContent>>("productPicker"))
            {
                @item2.Url
            }
    
    
            <p>@item.GetProperty("productPicker").Value()</p>
            <p>@item.GetProperty("quantity").Value()</p>
            <p>@item.GetProperty("cost").Value()</p>
    
    }
    

    }

  • Paul Wright (suedeapple) 277 posts 704 karma points
    Mar 21, 2019 @ 13:11
    Paul Wright (suedeapple)
    1

    Is "productPicker" just a regular ContentPicker? or a MultiNode Picker?

    If its just a single node picker, then the return type will be simply IPublishedContent

  • 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