Is there a function somewhere that can be used to restrict to a root node? Meaning, if an asset ID is passed, it is checked to see if it is found under the set root node, if it is, it returns true, if it is not under that root node, it returns false?
Root Node Function
Ok, I made a quick function that returns true if a certain asset is found under a set root node.
function checkRoot($id) { $root = $GLOBALS['SQ_SYSTEM']->am->getChildren($this->attr('root_node')); foreach($root as $key => $val) { if ($key == $id) { return TRUE; } }// End foreach }// End checkRoot
Not entirely sure this is the fastest method though...
It's probably faster to do a getParents() on the child asset and check to see if the root_node is in the parent list. You should get fewer results from getParents() than getChildren().
I don't remember the return format of getParents(), but you might be able to do something like (pseudocode):
$parents = getParents($id);
return isset($parents[$root_node]);
You may not even need a function to do that if there is no other logic in there.
[quote]I don't remember the return format of getParents(), but you might be able to do something like (pseudocode):
$parents = getParents($id);
return isset($parents[$root_node]);[/quote]
Nice one Greg! Thank you, this one worked perfectly and does seem to be a much quicker and simpler solution.
I appreciate the help!