Project:Family Tree
Version:6.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:jerdiggity
Status:closed (fixed)

Issue Summary

I added the following block_hook to the end of the family.module file.

It creates a block that shows the siblings of an individual. I've pasted the code for review. Please modify it as you see fit and add it as a feature to future versions, if possible. Thanks so much for contributing this module - it's really great!

/**
* Implementation of hook_block().
*
* Displays siblings of a Family Individual
*/
function family_block($op = 'list', $delta = 0) {
  switch ($op) {
    case 'list':
      $block[0]['info'] = t('Family: Siblings of Individual');
      return $block;

    case 'view':
      if (user_access('access family nodes')) {
        switch ($delta) {
          case 0:
            if (arg(0)=='node' && is_numeric(arg(1))) {
              $indiv = family_tree_get_info(arg(1));
              $fam = db_fetch_array(db_query("SELECT g.* FROM {family_group} g, {family_individual} i WHERE (g.nid=i.ancestor_group AND i.nid='%d')",$indiv['nid']));
              if ($fam) {
                $father = $fam['parent1'];
                $mother = $fam['parent2'];
                $items = array();
                $block['subject'] = t('Siblings');
                $families = db_query("SELECT * FROM {family_group} WHERE ((parent1='%d' AND parent1<>'') OR (parent2='%d' AND parent2<>''))",$father,$mother);
                if ($families) {
                  while($family=db_fetch_array($families)) {
                    if ($result=db_query("SELECT * FROM {family_individual} WHERE ancestor_group=%d AND nid!=%d order by birthdate",$family['nid'],$indiv['nid'])) {
                      while($sibling=db_fetch_array($result)) {
                        $items[] = family_make_name($sibling['nid'],TRUE) . ' (b: ' . $sibling['birthdate'] . ')';
                      }
                    }
                  }
                  $block['content'] = theme_item_list($items);
                }
              }
            }
            break;
        }
      }
      return $block;
  }
}

Comments

#1

Works great for me. Thanks.

#2

Assigned to:Anonymous» jerdiggity
Status:needs review» reviewed & tested by the community

Very nice! (Sorry for the late response... I just took over as maintainer of this module.) Will commit to new version after I make a few slight changes (elsewhere). Thanks!

jeremy

#3

Status:reviewed & tested by the community» fixed

Committed - thanks!

#4

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here