function field_label_plurals_preprocess_field in Field label plurals 7
Same name and namespace in other branches
- 8 field_label_plurals.module \field_label_plurals_preprocess_field()
Implements hook_preprocess_HOOK() for theme_field().
Alter the label before displaying it.
File
- ./
field_label_plurals.module, line 82 - Alter the field settings form to add a textfield for the singular and use those settings when preprocessing fields.
Code
function field_label_plurals_preprocess_field(&$variables) {
$element =& $variables['element'];
if (count($variables['items']) === 1) {
// If the textformatter module is enabled we do another check.
if (module_exists('textformatter') && (!isset($variables['items'][0]['#items']) || count($variables['items'][0]['#items']) > 1)) {
return;
}
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
if (isset($instance['field_label_plurals_singular']) && trim($instance['field_label_plurals_singular']) != '') {
$variables['label'] = check_plain($instance['field_label_plurals_singular']);
$element['#title'] = $instance['field_label_plurals_singular'];
}
}
}