Copied to clipboard

Flag this post as spam?

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


  • Barry Fogarty 493 posts 1129 karma points
    Jul 30, 2015 @ 16:18
    Barry Fogarty
    0

    Model.Descendants("alias").First() does not return first descendant

    I have an old site I have migrated from 6.0.5 to 6.2.5. No problems with upgrading, I did a full republish by clearing all the examine indexes and xml cache before restarting the site.

    The structure is somewhat like this:

    Home

    • News
    • Events (1)
    • About
      • Alumni
        • Events (2)
    • etc.......
    • Staff
      • Events (3)

    I have a macro on the home page that get a reference to the next Events page it finds in the tree using DynamicNode - Model.Descendants("Events").First(). However this is returning the events page marked with (2) above. Even more bizarre, Model.Descendants("Events") returns nodes 2,3,1 in that order. I have checked the umbraco.config XML and the Events nodes appear in the order I expect (1,2,3). What gives?

  • Casper Andersen 126 posts 508 karma points
    Aug 03, 2015 @ 09:26
    Casper Andersen
    0

    Firstly, i thought it had to be called Model.Content.Descendant()

    but that might be a new V7 thing but remember using model is all about the page you are on. And if you are using this in a macro, perhaps the model route that is being passed is wierd / different, try and do your code without the macro and see if that makes a different.

    Just a thought.

  • Barry Fogarty 493 posts 1129 karma points
    Aug 03, 2015 @ 13:04
    Barry Fogarty
    0

    Hi Casper, thanks for replying. FYI Model.Descendants is the correct syntax as the macro is using DynamicNode, and the Model in this case is the home page (dynamic) node as I would expect.

    This site has been upgraded from Umbraco 4.x previously. So the only thing I can come up with is the DynamicNode implementation in 6.2.5 is slightly different/buggy. Either that or it the underlying data has changed due to the upgrade. The really puzzling thing remains however, that the order of the nodes in the XML cache does not agree with the default order returned by Descendants() for a given node.

    Anyway I have worked around this issue by rewriting the macro in a different way. Thanks for your input though.

  • Barry Fogarty 493 posts 1129 karma points
    Aug 03, 2015 @ 13:08
    Barry Fogarty
    0

    Hmm - just remembered while writing this post about the path fixup patch from way back. I wonder if that is relevant in this situation?

    https://our.umbraco.org/projects/developer-tools/path-fixup/

    I upgraded from 6.0.5 this time but I am pretty sure it was a 4.x site before this upgrade.

Please Sign in or register to post replies

Write your reply to:

Draft