[eluser]m4rw3r[/eluser]
Formula for calculating the expected (the tree can contain gaps and duplicates) right value of a node:
Code:
R = L + 2 * D + 1
where
L = left value
R = expected right value
D = number of descendants to the node with left value L
I cannot use this formula in the model, because I don't know how many children the node has in the first place.
So you have to hard code the number of children to the root or, you can fetch the root first and then load the descendants:
Code:
$root = $this->MPTtree->get_node(1); // you can vary this number to change which node to be the root of the menu
$Categories = $this->MPTtree->get_descendants($root['LeftID'],$root['RightID'],true);
Formula for calculating the number of descendants of a node (used by count_descendants, so just use count_descendants (but it could be fun to know

)):
Code:
D = (R - (L + 1)) / 2
where
L = left value
R = right value
D = number of descendants to the node with left value L and right value R
I have also looked at the problem about loading models within models, and the only solution I've found is to use get_instance() to get the CI object and then use that directly when loading and calling other models (for some reason I can't call another model, that already has been loaded by the controller, in a model (I have to use the CI object instead of $this)).