Copied to clipboard

Flag this post as spam?

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


  • Dave 8 posts 79 karma points
    Mar 18, 2019 @ 12:53
    Dave
    0

    Nested, Nested Content - Possible Bug? Or am I doing something wrong?

    Hey guys, hopefully someone can point me in the right direction here, but im having trouble getting the value of a nested, nested content.

    To get the first level (simplified):

    var firstLevel = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("nestedPropName")
    

    Then to get the second level (Assuming this nested, nested dataType has content for simplicity):

    foreach(var item in firstLevel){
        var nestedNestedContent = item.GetPropertyValue<IEnumerable<IPublishedContent>>("nestedNestedPropName")
        // returns null
    }
    

    That comes out null But then doing this on the same dataset (Which I know isnt empty) does the right thing and returns true

    foreach(var item in firstLevel){
         var hasNestedContent = item.HasValue("nestedNestedPropName")
         // true
    }
    

    ...........Huh?! Very strange.

    Has anyone managed to successfully get a nested content item, from within a nested content item.

    Version : 7.13.2

    Cheers all.

  • Harry Spyrou 199 posts 560 karma points
    Mar 18, 2019 @ 15:18
    Harry Spyrou
    0

    Can you show the content tab of that specific Nested Content please?

  • Nik 1060 posts 4288 karma points MVP 2x c-trib
    Mar 18, 2019 @ 15:35
    Nik
    0

    Hey Dave,

    That does seem odd. It seems very similar to code I've seen before when accessing nested nested content and that's worked for me.

    What happens if you do this:

    var innerNestedContent = item.GetPropertyValue("nestedNestedPropName");
    <div>innerNestedContent</div>
    

    The aim of the code being to let the runtime tell your what type innerNestedContent is.

    Thanks

    Nik

Please Sign in or register to post replies

Write your reply to:

Draft