Copied to clipboard

Flag this post as spam?

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


  • David Amri 214 posts 740 karma points
    Feb 13, 2019 @ 15:05
    David Amri
    0

    Sort of nodes by each nodes nested content property value

    Hi,

    I'm trying to sort a number of nodes based upon each nodes nested content property value but I am failing miserable...

    • Node
      • nested content property "startDate"
    • Node
      • nested content property "startDate"
    • Node
      • nested content property "startDate"
  • Craig Mayers 164 posts 508 karma points
    Feb 13, 2019 @ 16:48
    Craig Mayers
    0

    Hi David,

    Can we see the code you are using thus far to try achieve this?

    Thanks

    Craig

  • David Amri 214 posts 740 karma points
    Feb 14, 2019 @ 08:19
    David Amri
    0

    Hi,

    This is what I have right now. I feel like it wouldn't be much help if I showed all the different solutions I have tried in achieving this so far. So this is the setup without trying to sort the nodes.

    @{
        // Get all info nodes in rootnode
        var infoPosts = rootPage.Descendants("infopost_d");
    
        // Each info post (how to sort these based upon each info post nested content DateTime property)
        foreach (var infoPost in infoPosts) 
        {
            // Get info post nested content
            var infoPuffs = infoPost.GetPropertyValue<IEnumerable<IPublishedContent>>("infoPuff");
    
            // Each nested content (each info post can only have one nested item so this foreach might not be necessary?)
            foreach (var infoPuff in infoPuffs)
            {
                // Get nested DateTime property
                // Render html
            }
        }
    }
    

    Best regards

Please Sign in or register to post replies

Write your reply to:

Draft