You are here

function hook_votingapi_views_formatters in Voting API 8.3

Same name and namespace in other branches
  1. 6.2 votingapi.api.php \hook_votingapi_views_formatters()
  2. 7.3 votingapi.api.php \hook_votingapi_views_formatters()
  3. 7.2 votingapi.api.php \hook_votingapi_views_formatters()

Declares callback functions for formatting a Voting API Views field.

Loads all votes for a given piece of content, then calculates and caches the aggregate vote results. This is only intended for modules that have assumed responsibility for the full voting cycle: the votingapi_set_vote() function recalculates automatically.

Parameters

mixed $field: A Views field object. This can be used to expose formatters only for tags, vote values, aggregate functions, etc.

Return value

array An array of key-value pairs, in which each key is a callback function and each value is a human-readable description of the formatter.

See also

votingapi_set_votes()

File

./votingapi.api.php, line 128
Provides hook documentation for the VotingAPI module.

Code

function hook_votingapi_views_formatters($field) {
  if ($field->field == 'value') {
    return [
      'mymodule_funky_formatter' => t('MyModule value formatter'),
    ];
  }
  if ($field->field == 'tag') {
    return [
      'mymodule_funky_tags' => t('MyModule tag formatter'),
    ];
  }
}