function UcTreeNode::add_child in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_catalog/classes/treenode.inc \UcTreeNode::add_child()
Determines if new child is an immediate descendant or not.
This function is completely dependent on the structure of the array returned by taxonomy_get_tree(). Each element in the array knows its depth in the tree and the array is a pre-order iteration of the logical tree structure. Therefore, if the parameter is more than one level deeper than $this, it should be passed to the last child of $this.
File
- uc_catalog/
uc_catalog.module, line 45 - Ubercart Catalog module.
Class
- UcTreeNode
- Data structure to mimic Drupal's menu system.
Code
function add_child(&$child) {
if ($child->depth - $this->depth == 1) {
$this->children[] = $child;
}
else {
$last_child =& $this->children[count($this->children) - 1];
$last_child
->add_child($child);
}
}