Copied to clipboard

Flag this post as spam?

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


  • Greg Fyans 124 posts 303 karma points
    Aug 17, 2012 @ 17:15
    Greg Fyans
    0

    Level 5 node doesn't load with nodeFactory

    Hi,

    I'm trying to load a Node which is in level 5 in my tree (I have confirmed this in umbraco.config).

    Loading nodes up to 5 works fine with this code, but not for level 5 itself. It's strange. What's going on here:

    public List<Core.Objects.SystemGoal> GetSystemGoals(int activityId)
            {
                var goals = new List<Core.Objects.SystemGoal>();
    
                var node = new Node(activityId);
    
                foreach (Node child in node.Children)
                {
                    if (child.NodeTypeAlias == Constants.UmbracoDocTypeAliases.SystemGoal)
                    {
                        var goal = new Core.Objects.SystemGoal();
                        goal.Id = child.Id;
                        goal.Name = child.GetProperty(Constants.UmbracoDocTypeProperties.Heading).Value;
                        goal.Description = child.GetProperty(Constants.UmbracoDocTypeProperties.SubHeading).Value;
    
                        goals.Add(goal);
                    }
                }
    
                return goals;
            }

    Node.Children is always empty even though I know there are children.

    Thanks,
    Greg.

  • Greg Fyans 124 posts 303 karma points
    Aug 19, 2012 @ 15:09
    Greg Fyans
    0

    Won't let me edit, but I'm using 4.8.1.

    Just like to clarify as I've actually described the problem wrong!

    It's not that the node isn't loading, this actually does work fine:

    var node = new Node(activityId);

    The problem is when I try to get children of that node, for some reason it's always empty even though it has children and they are all published:

    foreach (Node child in node.Children)
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies