nodefamily_relation_load_siblings

Versions
5
nodefamily_relation_load_siblings(&$node, $status = 1)

Load all siblings for a node. The sibling nodes will be loaded into the array $node->siblings and grouped by their parent.

Parameters

$node The node object or the node's id

$status The minimum status value a node must have to be included. Use 0 for all nodes.

Related topics

▾ 1 function calls nodefamily_relation_load_siblings()

nodefamily_relation_load_siblings in contributions/nodefamily/nodefamily.module
Load all siblings for a node. The sibling nodes will be loaded into the array $node->siblings and grouped by their parent.

Code

contributions/nodefamily/nodefamily.module, line 655

<?php
function nodefamily_relation_load_siblings(&$node, $status = 1) {

  if (!is_object($node)) {
    //$node is the nid
    $node2 = node_load($node);    
    return is_object($node2) ? nodefamily_relation_load_siblings($node2, $status) : FALSE;
  }
  //load the parents
  nodefamily_relation_load_parents($node, $status);
  $node->siblings = array();
  // find and load the children of the parents
  foreach ($node->parents as $parent) {
    $children = nodefamily_relation_load($parent->nid, $status);
    foreach ($children as $child) {
      // don't include current node in list of siblings
      if ($child->nid != $node->nid) {
        $node->siblings[][] = $child;
      }
    }
  }
  return $node->siblings;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.