taxonomy_get_vocabularies

Definition

taxonomy_get_vocabularies($type = NULL)
modules/taxonomy.module, line 417

Description

Return an array of all vocabulary objects.

Parameters

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

Code

<?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;
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.