--- relativity.module-2.4 2008-09-17 19:44:07.000000000 -0700 +++ relativity.module 2008-09-18 07:49:10.000000000 -0700 @@ -378,6 +378,14 @@ '#title' => t('Global Options'), ); + $group['global_options']['relativity_breadcrumb_trails'] = array( + '#type' => 'checkbox', + '#title' => t('Update the breadcrumb trails menu'), + '#return_value' => 1, + '#default_value' => variable_get('relativity_breadcrumb_trails', 0), + '#description' => t('If checked, the ancestor hiearchy of the page is used to create the breadcrumb trail menu.'), + ); + $group['global_options']['relativity_allow_types'] = array( '#type' => 'select', '#title' => t('Node types that can be involved in relationships'), @@ -1067,12 +1075,34 @@ break; case 'view': - if ($w = variable_get('relativity_'.$node->type.'_ancestor_weight', 0)) { + $do_breadcrumbs = variable_get('relativity_breadcrumb_trails', FALSE); + $ancestors_w = variable_get('relativity_'.$node->type.'_ancestor_weight', 0); + + if ($do_breadcrumbs || $ancestors_w) { $ancestors = relativity_load_ancestors($node); + if (is_array($ancestors) && count($ancestors) > 0) { - $node->content['relativity_ancestors'] = array( - '#value' => theme('relativity_show_ancestors', $node, $ancestors), - '#weight' => $w, - ); + if ($do_breadcrumbs) { + $breadcrumb[] = l(t('Home'), NULL); + foreach($ancestors as $ancestor) { + if (!is_array($ancestor)) { // Only handle single ancestors here + if (array_key_exists("path", $ancestor)) { + $breadcrumb[] = l($ancestor->title, $ancestor->path); + } else { + $breadcrumb[] = l($ancestor->title, 'node/'. $ancestor->nid); + } + } + } + if (count($breadcrumb) > 1) { + drupal_set_breadcrumb($breadcrumb); + } + } + + if ($ancestors_w) { + $node->content['relativity_ancestors'] = array( + '#value' => theme('relativity_show_ancestors', $node, $ancestors), + '#weight' => $ancestors_w, + ); + } } }