function hook_taxonomy_term_load

hook_taxonomy_term_load($terms)

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

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

Related topics

File

modules/taxonomy/taxonomy.api.php, line 106
Hooks provided by the Taxonomy module.

Code

function hook_taxonomy_term_load($terms) {
  $result = db_select('mytable', 'm')
    ->fields('m', array('tid', 'foo'))
    ->condition('m.tid', array_keys($terms), 'IN')
    ->execute();
  foreach ($result as $record) {
    $terms[$record->tid]->foo = $record->foo;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.api.php/function/hook_taxonomy_term_load/7.x