function taxonomy_term_load_multiple

7 taxonomy.module taxonomy_term_load_multiple($tids = array(), $conditions = array())
8 taxonomy.module taxonomy_term_load_multiple(array $tids = NULL)

Load multiple taxonomy terms based on certain conditions.

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

@todo Remove $conditions in Drupal 8.

Parameters

$tids: An array of taxonomy term IDs.

$conditions: (deprecated) An associative array of conditions on the {taxonomy_term} table, where the keys are the database fields and the values are the values those fields must have. Instead, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs loadable by this function.

Return value

An array of term objects, indexed by tid. When no results are found, an empty array is returned.

See also

entity_load()

EntityFieldQuery

11 calls to taxonomy_term_load_multiple()
hook_field_formatter_prepare_view in modules/field/field.api.php
Allow formatters to load information for field values being displayed.
TaxonomyLoadMultipleTestCase::testTaxonomyTermMultipleLoad in modules/taxonomy/taxonomy.test
Create a vocabulary and some taxonomy terms, ensuring they're loaded correctly using taxonomy_term_load_multiple().
TaxonomyTermFunctionTestCase::testTermDelete in modules/taxonomy/taxonomy.test
taxonomy_autocomplete_validate in modules/taxonomy/taxonomy.module
Form element validate handler for taxonomy term autocomplete element.
taxonomy_field_formatter_prepare_view in modules/taxonomy/taxonomy.module
Implements hook_field_formatter_prepare_view().

... See full list

File

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

Code

function taxonomy_term_load_multiple($tids = array(), $conditions = array()) {
  return entity_load('taxonomy_term', $tids, $conditions);
}

Comments

function taxonomy_term_get_by_vid($vid) {
  $query = new EntityFieldQuery();
  $result = $query
  ->entityCondition('entity_type', 'taxonomy_term')
  ->propertyCondition('vid', (int) $vid, '=')
  ->execute();
  return $result['taxonomy_term'];
}

Alternatively, you could just use the conditions on this function:

taxonomy_term_load_multiple(array(), array('vid' => $vid));

The $conditions argument is deprecated and will be removed in Drupal 8.

See also taxonomy_get_tree().