function hook_votingapi_metadata_alter in Voting API 6.2
Same name and namespace in other branches
- 8.3 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()
Adds to or alters 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 VotingAPI tables, and contains an array with (minimally) 'name' and 'description' keys. Modules can add extra keys to their entries if desired.
Parameters
$data: An alterable array of aggregate vote results.
See also
1 invocation of hook_votingapi_metadata_alter()
- votingapi_metadata in ./
votingapi.module - Returns metadata about tags, value_types, and results defined by vote modules.
File
- ./
votingapi.api.php, line 70 - 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'] = array(
'name' => t('Bread'),
'description' => t('The quality of the food at a restaurant.'),
'module' => 'mymodule',
);
$data['tags']['circuses'] = array(
'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'] = array(
'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'] = array(
'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',
);
}