taxonomy_vocabulary_load_multiple

7 taxonomy.module taxonomy_vocabulary_load_multiple($vids = array(), $conditions = array())
8 taxonomy.module taxonomy_vocabulary_load_multiple($vids = array(), array $conditions = array())

Load multiple taxonomy vocabularies based on certain conditions.

This function should be used whenever you need to load more than one vocabulary from the database. Terms are loaded into memory and will not require database access if loaded again during the same page request.

Parameters

$vids: An array of taxonomy vocabulary IDs, or FALSE to load all vocabularies.

$conditions: An array of conditions to add to the query.

Return value

An array of vocabulary objects, indexed by vid.

See also

entity_load()

4 calls to taxonomy_vocabulary_load_multiple()

File

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

Code

function taxonomy_vocabulary_load_multiple($vids = array(), $conditions = array()) {
  return entity_load('taxonomy_vocabulary', $vids, $conditions);
}

Comments

Why would I ever use this function?

Why would I ever use this function?

This function does nothing different than entity_load other than adding the type taxonomy_vocabulary hard coded.

I was hoping that this function would accept conditions like the machine_name of the taxonomy_vocabulary bundle and give me all the entities object for that taxonomy.

If there is another way to accomplish this please let me know.

This is how I am getting it now

$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'taxonomy_vocabulary', '=')
->propertyCondition('machine_name', 'cities_and_towns', '=')
;
$aoVids = $query->execute();

$aVids = mmg_regions_collapseArrayValue($aoVids[taxonomy_vocabulary],'vid');

$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'taxonomy_term', '=')
->propertyCondition('vid', $aVids[0], '=')
;

$aoAllVids = $query->execute();
$aAllVids = mmg_regions_collapseArrayValue($aoAllVids['taxonomy_term'],'tid');
$aoCities = entity_load('taxonomy_term', $aAllVids);

function mmg_regions_collapseArrayValue($aEntityList,$key){
  $aCollapsed = array();
  foreach ($aEntityList as $entityID) {
   $aCollapsed[] = $entityID->$key;
  }
  return $aCollapsed;
}

taxonomy_vocabulary_machine_name_load()

Sounds like you'll be wanting this one;
http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/func...

Thanks to dman for the pointer...

Login or register to post comments