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?
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.
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.
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
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?
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.
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.
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.
is working on a reply...