You are here

function nodehierarchy_get_node_children in Node Hierarchy 7.4

Get the children of the given node.

3 calls to nodehierarchy_get_node_children()
nodehierarchy_alter_node_delete_confirm_form in ./nodehierarchy.admin.inc
Add Node Hierarchy delete options to the node delete confirm form.
nodehierarchy_children_form in ./nodehierarchy.admin.inc
Built the children tab form.
nodehierarchy_delete_descendants in ./nodehierarchy.admin.inc
Delete all of the descendants of the given node.

File

./nodehierarchy.api.inc, line 97
API functions for Node Hierarchy

Code

function nodehierarchy_get_node_children($node, $limit = FALSE) {
  $pnid = $node;
  if (is_object($node)) {
    $pnid = $node->nid;
  }
  $query = db_select('nodehierarchy', 'nh')
    ->fields('nh')
    ->fields('n', array(
    'title',
  ))
    ->where('pnid = :pnid', array(
    ':pnid' => $pnid,
  ))
    ->orderBy('cweight', 'ASC');
  $query
    ->leftJoin('node', 'n', 'nh.cnid = n.nid');
  if ($limit) {
    $query
      ->range(0, $limit);
  }
  $result = $query
    ->execute()
    ->fetchAll();
  $children = array();
  foreach ($result as $item) {
    $children[] = $item;
  }
  return $children;
}