function hook_taxonomy_term_load

Act on taxonomy terms when loaded.

Modules implementing this hook can act on the term objects returned by taxonomy_term_load_multiple().

For performance reasons, information to be added to term objects should be loaded in a single query for all terms where possible.

Since terms are stored and retrieved from cache during a page request, avoid altering properties provided by the {taxonomy_term_data} table, since this may affect the way results are loaded from cache in subsequent calls.

Parameters

array $terms: An array of taxonomy term entities, indexed by tid.

Related topics

2 functions implement hook_taxonomy_term_load()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_taxonomy_term_load in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_taxonomy_term_load().
taxonomy_test_taxonomy_term_load in drupal/core/modules/system/tests/modules/taxonomy_test/taxonomy_test.module
Implements hook_taxonomy_term_load().

File

drupal/core/modules/taxonomy/taxonomy.api.php, line 128
Hooks provided by the Taxonomy module.

Code

function hook_taxonomy_term_load(array $terms) {
  $result = db_query('SELECT tid, foo FROM {mytable} WHERE tid IN (:tids)', array(
    ':tids' => array_keys($terms),
  ));
  foreach ($result as $record) {
    $terms[$record->tid]->foo = $record->foo;
  }
}