You are here

function hook_term_update_index in Term Search 7

Act on a term being indexed for search.

Modules implementing this hook will return additional html text to add to the search index for a specific term. Note that the term has already been rendered using the 'search_index' view mode.

Parameters

$term: The term object that is being indexed for search.

Return value

A string (can include html) that will be added to the rendered term before indexing for search.

1 invocation of hook_term_update_index()
term_search_update_index in ./term_search.module
Implements hook_update_index().

File

./term_search.api.php, line 38
This file contains no working PHP code; it exists to provide additional documentation for doxygen as well as to document hooks in the standard Drupal manner.

Code

function hook_term_update_index($term) {
  $text = '';
  $query = db_select('users', 'u');
  $query
    ->rightJoin('field_data_field_affiliation', 'a', 'a.entity_id=u.uid');
  $uids = $query
    ->addField('u', 'uid')
    ->condition('a.field_affiliation_tid', $term->tid)
    ->countQuery()
    ->execute()
    ->fetchField();
  foreach ($uids as $uid) {
    $account = user_load($uid);
    $text .= user_view($account, 'department_index');
  }
  return $text;
}