You are here

function nodewords_load_tags in Nodewords: D6 Meta Tags 6

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

Load tags from table.

9 calls to nodewords_load_tags()
nodewords_form in ./nodewords.module
Return the form used to set the meta tags values.
nodewords_form_taxonomy_form_term_alter in ./nodewords.module
Implements hook_form_FORM_ID_alter().
nodewords_form_taxonomy_form_vocabulary_alter in ./nodewords.module
Implements hook_form_FORM_ID_alter().
nodewords_nodeapi in ./nodewords.module
Implements hook_nodeapi().
nodewords_preprocess_page in ./nodewords.module
Implements hook_preprocess_page().

... See full list

File

./nodewords.module, line 940
Implement an API that other modules can use to implement meta tags.

Code

function nodewords_load_tags($type = NODEWORDS_TYPE_DEFAULT, $id = 0) {
  static $queries = array();

  // If the metatags haven't been loaded before, load them.
  if (!isset($queries[$type][$id])) {
    $result = db_query("SELECT * FROM {nodewords} WHERE type = %d AND id = %d", $type, $id);
    $tags = array();
    $tags_info = nodewords_get_possible_tags();
    while ($row = db_fetch_object($result)) {
      if (isset($tags_info[$row->name])) {
        $tags[$row->name] = unserialize($row->content);
      }
    }

    // If no metatags are found for this term, try loading the vocabulary's.
    if (empty($tags) && $type == NODEWORDS_TYPE_TERM) {
      $tags = nodewords_load_tags(NODEWORDS_TYPE_VOCABULARY, db_result(db_query('SELECT vid FROM {term_data} WHERE tid = %d', $id)));
    }

    // Cache the metatags for later.
    $queries[$type][$id] = $tags;
  }
  return $queries[$type][$id];
}