You are here

function nodewords_get_term in Nodewords: D6 Meta Tags 6.3

Same name and namespace in other branches
  1. 6 nodewords.module \nodewords_get_term()
  2. 6.2 nodewords.module \nodewords_get_term()

Return the term object matching a term ID. This is a modified version of taxonomy_get_term() which uses db_rewrite_sql().

Parameters

$tid: A term's ID.

$uid: The user ID; if not passed, the function will use the global user ID.

Return value

A term object, or FALSE. Results are statically cached.

File

./nodewords.module, line 456
Implement an version that other modules can use to add meta tags.

Code

function nodewords_get_term($tid, $uid = NULL) {
  global $user;
  static $terms = array();
  if (!isset($uid)) {
    $uid = $user->uid;
  }
  if (!isset($terms[$uid][$tid])) {
    $terms[$uid][$tid] = db_fetch_object(db_query(db_rewrite_sql('SELECT * FROM {term_data} t WHERE t.tid = %d', 't', 'tid'), $tid));
  }
  return !empty($terms[$uid][$tid]) ? $terms[$uid][$tid] : FALSE;
}