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 176 posts 659 karma points
    3 days ago
    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 485 karma points
    2 days ago
    Craig Mayers
    0

    Hi David,

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

    Thanks

    Craig

  • David Amri 176 posts 659 karma points
    1 day ago
    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