function chado_feature_load

2.x tripal_feature.chado_node.inc chado_feature_load($nodes)
3.x tripal_feature.chado_node.inc chado_feature_load($nodes)
1.x tripal_feature.module chado_feature_load($node)

When a node is requested by the user this function is called to allow us to add auxiliary data to the node object.

Related topics

File

tripal_feature/tripal_feature.module, line 957
@todo Add file header description

Code

function chado_feature_load($node) {

  // get the feature details from chado
  $feature_id = chado_get_id_for_node('feature', $node);

  $values = array('feature_id' => $feature_id);
  $feature = tripal_core_generate_chado_var('feature', $values);

  // by default, the titles are saved using the unique constraint.  We will
  // keep it the same, but remove the duplicate name if the unique name and name
  // are identical
  $title_type = variable_get('chado_feature_title', 'unique_constraint');
  if ($title_type == 'unique_constraint') {
    if (strcmp($feature->name, $feature->uniquename) == 0) {
      $node->title = $feature->name . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species;
    }
    // in previous version of Tripal, the feature title was simply the unique name. 
    // so, we recreate the title just to be sure all of our feature pages are consistent
    else {
      $node->title = $feature->name . ", " . $feature->uniquename . " (" . $feature->type_id->name . ") " . $feature->organism_id->genus . " " . $feature->organism_id->species;
    }
  }
  // set the title to be the feature name or uniquename as configured
  if ($title_type == 'feature_name') {
    $node->title = $feature->name;
  }
  if ($title_type == 'feature_unique_name') {
    $node->title = $feature->uniquename;
  }

  $additions = new stdClass();
  $additions->feature = $feature;
  return $additions;
}