taxonomy_get_vocabularies

Versions
4.6 – 6
taxonomy_get_vocabularies($type = NULL)
7
taxonomy_get_vocabularies()

Return an array of all vocabulary objects.

Parameters

$type If set, return only those vocabularies associated with this node type.

▾ 2 functions call taxonomy_get_vocabularies()

taxonomy_form_all in modules/taxonomy.module
Generate a set of options for selecting a term from all vocabularies. Can be passed to form_select.
taxonomy_overview in modules/taxonomy.module
Generate a tabular listing of administrative functions for vocabularies.

Code

modules/taxonomy.module, line 417

<?php
function taxonomy_get_vocabularies($type = NULL) {
  if ($type) {
    $result = db_query("SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", $type);
  }
  else {
    $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid ORDER BY v.weight, v.name');
  }

  $vocabularies = array();
  $node_types = array();
  while ($voc = db_fetch_object($result)) {
    $node_types[$voc->vid][] = $voc->type;
    unset($voc->type);
    $voc->nodes = $node_types[$voc->vid];
    $vocabularies[$voc->vid] = $voc;
  }

  return $vocabularies;
}
?>
Login or register to post comments
 
 

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.