function starrating_field_formatter_settings_summary in Star Rating 7.2
Implements hook_field_formatter_settings_summary(). Displays infos here /admin/structure/types/manage/node_type_name/display
File
- ./
starrating.module, line 115 - Provides star rating field, formatter and widget using Field API. star rating field is based on integer value and convert it to the HTML code that displays series of icons. The formatter supports not only star rating field type but also…
Code
function starrating_field_formatter_settings_summary($field, $instance, $view_mode) {
//only display settings for starrating formatter
if ($instance['display']['default']['type'] == 'starrating_rating_value_formatted') {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$options = array(
'type' => 'file',
'weight' => 10,
'group' => CSS_DEFAULT,
);
$css_file = $settings['icon_type'] . '.css';
drupal_add_css(drupal_get_path('module', 'starrating') . '/icons/' . $css_file, $options);
//currently we only support list_integer
if ($field['type'] == 'list_integer') {
//get first array value as it is the minimum value
reset($field['settings']['allowed_values']);
$min = current($field['settings']['allowed_values']);
$max = count($field['settings']['allowed_values']) - 1;
}
else {
drupal_set_message("Something went wrong. Only list_inetger is crrently supported");
}
$rate = $max - 1;
// sample data to be used for summary view so we remove one to see if fill blank setting works (visually)
$summary = starrating_field_formatter_execute($rate, $min, $max, $settings['icon_type'], $settings['icon_color'], $settings['fill_blank']);
return $summary;
}
}