Copied to clipboard

Flag this post as spam?

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

  • Rick 32 posts 135 karma points
    Nov 08, 2019 @ 20:58

    Weird foreach children issue with new node

    Hey All,

    Umbraco v7.10.4

    Something odd just started happening on a site we are working with a client on. The client added a new node and we have simple scripts to generate the main menu by cycling through the nodes (standard stuff). This node also has the umbracoNaviHide field that there is also an issue with.

    Whats odd is that the node is appearing twice on the main menu. I couldn't see anything obvious in the script so I created a quick testing page so I could dump details without disruption to the site. On there I just put a little snippet where 'home' is the root of the site...

    var home = Umbraco.Content(1053);
    foreach (var n in home.Children.Where("Visible")) {
      <div>@n.Id / @n.Name</div>

    Sure enough, the node in question appears twice in the list with both the same NodeId and NodeName but its the only one with this behavior. I emptied the Recycle Bin (seen odd things related to that before), cycled the application pool and did a few Save and Publishes and nothing changed.

    I've also noticed that for both this node and all of the children nodes, the umbracoNaviHide is now reversed. eg - If I check the box (to hide) it shows up, If I uncheck it (to show) it hides.

    I got a little under the hood and don't see anything in the umbracoNode table that is a big red flag. Obviously something under the hood is messed up, but I'm not sure where else to look.

    Normally, I would just shrug and recreate the page, but the client already has created ~30 children pages and aside from just a volume of work involved, I'm worried that if we just recreate the parent and move the children the issue will move with them.

    Anyone ever seen anything like this before and can point me in the right direction?

    Thanks in advance, Rick

  • Steve Megson 147 posts 918 karma points c-trib
    Nov 12, 2019 @ 08:38
    Steve Megson

    What does the node look like in umbraco.config? In theory, home.Children is simply returning a list of the child XML nodes, so for a node to be returned twice it must appear twice in umbraco.config.

    In that case, I'd expect it to be fixed by a "Republish entire site", since that rebuilds umbraco.config from the database. That wouldn't explain how it originally ended up appearing twice, though.

  • Rick 32 posts 135 karma points
    Nov 12, 2019 @ 13:14


    Thank you! I looked in the umbraco.config and it did appear to be listed in there twice. As suggested, I ran the Republish Entire Site and it appears to have resolved both the duplicate node and the reversed umbracoNaviHide issue.

    Thanks for the ProTip...I owe you a coffee!

Please Sign in or register to post replies

Write your reply to: