function nodehierarchy_get_children in Node Hierarchy 6
Same name and namespace in other branches
- 5 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 818
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";
$qparam = $nid;
}
else {
// load list of NH-managed types
$typelist = _nodehierarchy_get_types();
if (empty($typelist)) {
$query = "SELECT n.nid FROM {node} n LEFT JOIN {nodehierarchy} h ON h.nid = n.nid WHERE h.parent = 0 ORDER BY h.order_by ASC";
$qparam = $nid;
}
else {
$qplaceholders = db_placeholders($typelist, 'varchar');
$query = "SELECT n.nid FROM {node} n LEFT JOIN {nodehierarchy} h ON h.nid = n.nid WHERE n.type IN ({$qplaceholders}) AND h.parent = 0 ORDER BY h.order_by ASC";
$qparam = $typelist;
}
}
if ($pager) {
$result = pager_query($query, $pager, 0, NULL, $qparam);
}
else {
$result = db_query($query, $qparam);
}
while ($node = db_fetch_object($result)) {
$children[] = $node->nid;
}
return $children;
}