Community Documentation

taxonomy_get_vocabulary

5 taxonomy.module taxonomy_get_vocabulary($vid)

Return the vocabulary object matching a vocabulary ID.

Parameters

$vid: The vocabulary's ID

Return value

Object The vocabulary object with all of its metadata. Results are statically cached.

▾ 10 functions call taxonomy_get_vocabulary()

forum_view in modules/forum/forum.module
Implementation of hook_view().
taxonomy_admin_vocabulary_edit in modules/taxonomy/taxonomy.module
Page to edit a vocabulary.
taxonomy_del_vocabulary in modules/taxonomy/taxonomy.module
Delete a vocabulary.
taxonomy_form in modules/taxonomy/taxonomy.module
Generate a form element for selecting terms from a vocabulary.
taxonomy_form_term in modules/taxonomy/taxonomy.module
taxonomy_node_validate in modules/taxonomy/taxonomy.module
Make sure incoming vids are free tagging enabled.
taxonomy_overview_terms in modules/taxonomy/taxonomy.module
Display a tree of all the terms in a vocabulary, with options to edit each one.
taxonomy_term_path in modules/taxonomy/taxonomy.module
For vocabularies not maintained by taxonomy.module, give the maintaining module a chance to provide a path for terms in that vocabulary.
taxonomy_vocabulary_confirm_delete in modules/taxonomy/taxonomy.module
theme_forum_display in modules/forum/forum.module
Format the forum body.

File

modules/taxonomy/taxonomy.module, line 1143
Enables the organization of content into categories.

Code

<?php
function taxonomy_get_vocabulary($vid) {
  static $vocabularies = array();

  if (!array_key_exists($vid, $vocabularies)) {
    $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
    $node_types = array();
    while ($voc = db_fetch_object($result)) {
      $node_types[] = $voc->type;
      unset($voc->type);
      $voc->nodes = $node_types;
      $vocabularies[$vid] = $voc;
    }
  }

  return $vocabularies[$vid];
}
?>

Comments

Future version of this method

Use taxonomy_vocabulary_load for Drupal 6 onwards.

Login or register to post comments