function chado_node_add_token_format

2.x tripal_core.chado_nodes.title_and_path.api.inc chado_node_add_token_format($application, $content_type, $format, $tokens)
3.x tripal_core.chado_nodes.title_and_path.inc chado_node_add_token_format($application, $content_type, $format, $tokens)

Save a format to be used by chado_get_node_title() or chado_get_node_url()

Parameters

$application: What the format is to be applied to. For example 'title' for generating node titles and 'path' for generating node paths

$content_type: The name of the content type this format applies to (ie: $node->type)

$format: A string including tokens used to generate the title/path (which is based on $application)

$tokens: An array of tokens generated by chado_node_generate_tokens(). This is saved to ensure the tokens that are available when the format is created are still available when it's used

4 calls to chado_node_add_token_format()
chado_add_admin_form_set_title_form_submit in tripal_core/api/tripal_core.chado_nodes.title_and_path.api.inc
Implements hook_form_submit(). SUBMIT: Actually add the format specified by chado_add_admin_form_set_title()
chado_add_admin_form_set_url_form_submit in tripal_core/api/tripal_core.chado_nodes.title_and_path.api.inc
Implements hook_form_submit(). SUBMIT: Actually add the format specified by chado_add_admin_form_set_title()
chado_node_get_title_format in tripal_core/api/tripal_core.chado_nodes.title_and_path.api.inc
Get the title format for a specific content type
chado_node_get_url_format in tripal_core/api/tripal_core.chado_nodes.title_and_path.api.inc
Get the url format for a specific content type

File

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

Code

function chado_node_add_token_format($application, $content_type, $format, $tokens) {

  if (is_array($tokens)) {
    $tokens = serialize($tokens);
  }

  $record = array(
    'content_type' => $content_type,
    'application' => $application,
    'format' => $format,
    'tokens' => $tokens
  );

  // Check if it already exists
  $id = db_query('SELECT tripal_format_id FROM {tripal_token_formats} WHERE content_type=:type AND application=:application', array(':type' => $record['content_type'], ':application' => $record['application']))->fetchField();
  if ($id) {
    drupal_write_record('tripal_token_formats', $record, array('content_type', 'application'));
  }
  else {
    drupal_write_record('tripal_token_formats', $record);
  }

}