function _nodehierarchy_nodes_by_type in Node Hierarchy 7.4
Get a tree of nodes of the given type.
1 call to _nodehierarchy_nodes_by_type()
- _nodehierarchy_parent_options in ./
nodehierarchy.admin.inc - Return a list of menu items that are valid possible parents for the given node.
File
- ./
nodehierarchy.admin.inc, line 541 - Admin functions for Node Hierarchy
Code
function _nodehierarchy_nodes_by_type($types, $pnid = NULL, $depth = 0) {
$out = array();
if ($types) {
$query = db_select('node', 'n')
->fields('n', array(
'nid',
'type',
'title',
'uid',
'status',
))
->fields('nh', array(
'cweight',
'pnid',
))
->condition('n.type', $types, 'IN')
->orderBy('nh.cweight', 'ASC');
$query
->leftJoin('nodehierarchy', 'nh', 'nh.cnid = n.nid');
$result = $query
->execute();
foreach ($result as $item) {
$out[$item->nid] = $item;
}
}
return $out;
}