Contributions API

Modules in 5

nodefamily_relation_load_all_nids

Definition

nodefamily_relation_load_all_nids(&$node)
contributions/nodefamily/nodefamily.module, line 546

Description

Load all children's nids for a node. This function doesn't obey node_access for the current user, it just loads all children. The children's node-ids will be loaded into the array $node->children.

Parameters

$node The node object or the node's id

Related topics

Namesort iconDescription
Implementation of node - node relation API

Code

<?php
function nodefamily_relation_load_all_nids(&$node) {

  if (!is_object($node)) {
    //$node is the nid
    $node2 = node_load($node);    
    return is_object($node2) ? nodefamily_relation_load_all_nids($node2) : FALSE;
  }

  $result = db_query("SELECT child_nid FROM {nodefamily} WHERE parent_nid = %d", $node->nid);
  
  $node->children = array();
  while ($row = db_fetch_object($result)) {
    $node->children[$row->child_nid] = $row->child_nid;
  }
  return $node->children;
}
?>