I am trying to use the nodeFactory to navigate this tree. If my current node is NodeA2 and I want to get to NodeB2, I thought I could do something like this:
will get the Content node and NodeA and NodeB are both children. A little weird since all the nodes are children of the Content node but the Content node is not a parent of its children???
Just my thoughts. The root node is not a traditional node. If you check the database the parent of the root node is also -1, the root node. And in the data/umbraco.config it is specified as <root> vs <node>. So since it's not a traditional node, it functions a little bit differently.
How do I get sibling nodes?
I have a content tree that looks like this:
<Content>
<NodeA>
<NodeA1/>
<NodeA2/>
<NodeA3/>
</NodeA>
<NodeB>
<NodeB1/>
<NodeB2/>
</NodeB>
</Content>
I am trying to use the nodeFactory to navigate this tree. If my current node is NodeA2 and I want to get to NodeB2, I thought I could do something like this:
Node root = Node.GetCurrent();
while(root.Parent != null)
root = root.Parent;
Node NodeB2 = root.Children[1].Children[1];
However, the loop to get the root node stops at NodeA because the parent of NodeA is null. How am I supposed to get to the sibling nodes?
It looks like this:
Node root = new Node(-1);
will get the Content node and NodeA and NodeB are both children. A little weird since all the nodes are children of the Content node but the Content node is not a parent of its children???
Just my thoughts. The root node is not a traditional node. If you check the database the parent of the root node is also -1, the root node. And in the data/umbraco.config it is specified as <root> vs <node>. So since it's not a traditional node, it functions a little bit differently.
-Chris
is working on a reply...