You are here

function data_taxonomy_save_term_name in Data 6

Save a term, create a new one if it does not exist yet.

Parameters

$name: A taxonomy term name to look up and save.

$vid: A <em>numeric</em> vocabulary id (vid).

Return value

A taxonomy term array.

2 calls to data_taxonomy_save_term_name()
data_taxonomy_save_tags in data_taxonomy/data_taxonomy.module
Explode terms from typed input, create new terms.
_data_taxonomy_save_terms in data_taxonomy/data_taxonomy.module
Helper function, saves a series of taxonomy terms for a record.

File

data_taxonomy/data_taxonomy.module, line 298
Hooks and API functions for Data Node module.

Code

function data_taxonomy_save_term_name($name, $vid) {
  if ($term = data_taxonomy_lookup_term($name, $vid)) {
    return $term;
  }
  $term = array(
    'vid' => $vid,
    'name' => $name,
  );
  taxonomy_save_term($term);
  return $term;
}