function chado_get_node_title

2.x tripal_core.chado_nodes.title_and_path.api.inc chado_get_node_title($node)
3.x tripal_core.chado_nodes.title_and_path.inc chado_get_node_title($node)

Get the title of a node based on the Title Format set in the admin section of the module. If the format has not yet been set than the the unique constrain and name fields will be used to generate a default format

Parameters

$node: The node object

Related topics

30 calls to chado_get_node_title()
chado_analysis_load in legacy/tripal_analysis/includes/tripal_analysis.chado_node.inc
Implements hook_load(). When a node is requested by the user this function is called to allow us to add auxiliary data to the node object.
chado_contact_load in legacy/tripal_contact/includes/tripal_contact.chado_node.inc
Implements hook_load().
chado_featuremap_load in legacy/tripal_featuremap/includes/tripal_featuremap.chado_node.inc
Implements hook_load().
chado_feature_load in legacy/tripal_feature/includes/tripal_feature.chado_node.inc
Implements hook_load().
chado_library_load in legacy/tripal_library/includes/tripal_library.chado_node.inc
Implements hook_load().

... See full list

File

legacy/tripal_core/api/tripal_core.chado_nodes.title_and_path.inc, line 196
Contains API functions to set titles and paths for all chado nodes

Code

function chado_get_node_title($node) {
  $content_type = $node->type;

  // Get the tokens and format
  $tokens = array(); // this will be set by chado_node_get_title_format
  $title = chado_node_get_title_format($content_type, $tokens);

  // Determine which tokens were used in the format string
  if (preg_match_all('/\[[^]]+\]/', $title, $used_tokens)) {

    // Get the value for each token used
    foreach ($used_tokens[0] as $token) {
      $token_info = $tokens[$token];
      if (!empty($token_info)) {
        $value = chado_get_token_value($token_info, $node);
        $title = str_replace($token, $value, $title);
      }
    }
  }
  else {
    return $title;
  }

  return $title;
}