taxonomy_get_synonym_root

Definition

taxonomy_get_synonym_root($synonym, $reset = FALSE)
modules/taxonomy/taxonomy.module, line 906

Description

Return the term object that has the given string as a synonym.

Parameters

$synonym The string to compare against.

$reset Whether to reset the internal cache for this synonym.

Return value

A term object, or FALSE if no matching term is found.

Code

<?php
function taxonomy_get_synonym_root($synonym, $reset = FALSE) {
  static $synonyms = array();

  if ($reset) {
    unset($synonyms[$synonym]);
  }

  if (!isset($synonyms[$synonym])) {
    $synonyms[$synonym] = db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = :name", array(':name' => $synonym))->fetch();
  }
  return $synonyms[$synonym];
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.