You are here

function hook_file_entity_search_result in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.api.php \hook_file_entity_search_result()

Act on a file being displayed as a search result.

This hook is invoked from file_entity_search_execute(), after file_load() and file_view() have been called.

Parameters

object $file: The file being displayed in a search result.

Return value

array Extra information to be displayed with search result. This information should be presented as an associative array. It will be concatenated with the file information (filename) in the default search result theming.

See also

template_preprocess_search_result()

search-result.tpl.php

1 invocation of hook_file_entity_search_result()
file_entity_search_execute in ./file_entity.module
Implements hook_search_execute().

File

./file_entity.api.php, line 234
Hooks provided by the File Entity module.

Code

function hook_file_entity_search_result($file) {
  $file_usage_count = db_query('SELECT count FROM {file_usage} WHERE fid = :fid', array(
    'fid' => $file->fid,
  ))
    ->fetchField();
  return array(
    'file_usage_count' => format_plural($file_usage_count, '1 use', '@count uses'),
  );
}