You are here

function nodehierarchy_get_children in Node Hierarchy 5

Same name and namespace in other branches
  1. 6 nodehierarchy.module \nodehierarchy_get_children()

Get the children of the given node.

3 calls to nodehierarchy_get_children()
nodehierarchy_delete_children in ./nodehierarchy.module
Delete the nodehierarchy information when a node is deleted.
nodehierarchy_get_descendant_list in ./nodehierarchy.module
Get the descendant tree for the given node.
nodehierarchy_get_node_children_list in ./nodehierarchy.module
Display a list of nodes with nodehierarchy actions.

File

./nodehierarchy.module, line 776
A module to make nodes hierarchical.

Code

function nodehierarchy_get_children($nid, $pager = FALSE) {
  $children = array();
  if ($nid) {
    $query = "SELECT h.nid FROM {nodehierarchy} h WHERE  h.parent = %d ORDER BY h.order_by ASC";
  }
  else {
    $query = "SELECT n.nid FROM {node} n LEFT JOIN {nodehierarchy} h ON h.nid = n.nid WHERE h.parent = 0 OR h.parent IS NULL ORDER BY h.order_by ASC";
  }
  if ($pager) {
    $result = pager_query($query, $pager, 0, NULL, $nid);
  }
  else {
    $result = db_query($query, $nid);
  }
  while ($node = db_fetch_object($result)) {
    $children[] = $node->nid;
  }
  return $children;
}