Closed (fixed)
Project:
Family Tree
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
13 Oct 2009 at 21:36 UTC
Updated:
18 Mar 2010 at 13:50 UTC
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
Comment #1
John Bryan commentedWorks great for me. Thanks.
Comment #2
jerdiggity commentedVery 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
Comment #3
jerdiggity commentedCommitted - thanks!