function hook_votingapi_metadata_alter in Voting API 8.3
Same name and namespace in other branches
- 6.2 votingapi.api.php \hook_votingapi_metadata_alter()
- 7.3 votingapi.api.php \hook_votingapi_metadata_alter()
- 7.2 votingapi.api.php \hook_votingapi_metadata_alter()
Allows altering metadata describing Voting tags, value_types, and functions.
If your module uses custom tags or value_types, or calculates custom aggregate functions, please implement this hook so other modules can properly interperet and display your data.
Three major bins of data are stored: tags, value_types, and aggregate result functions. Each entry in these bins is keyed by the value stored in the actual Voting API tables, and contains an array with (minimally) 'name' and 'description' keys. Modules can add extra keys to their entries if desired.
Parameters
array $data: An alterable array of aggregate vote results.
See also
votingapi_metadata()
File
- ./
votingapi.api.php, line 83 - Provides hook documentation for the VotingAPI module.
Code
function hook_votingapi_metadata_alter(&$data) {
// Document several custom tags for rating restaurants and meals.
$data['tags']['bread'] = [
'name' => t('Bread'),
'description' => t('The quality of the food at a restaurant.'),
'module' => 'mymodule',
];
$data['tags']['circuses'] = [
'name' => t('Circuses'),
'description' => t('The quality of the presentation and atmosphere at a restaurant.'),
'module' => 'mymodule',
];
// Document two custom aggregate function.
$data['functions']['standard_deviation'] = [
'name' => t('Standard deviation'),
'description' => t('The standard deviation of all votes cast on a given piece of content. Use this to find controversial content.'),
'module' => 'mymodule',
];
$data['functions']['median'] = [
'name' => t('Median vote'),
'description' => t('The median vote value cast on a given piece of content. More accurate than a pure average when there are a few outlying votes.'),
'module' => 'mymodule',
];
}