function shs_field_views_data_alter in Simple hierarchical select 7
Implements hook_field_views_data_alter().
File
- ./
shs.module, line 222 - Provides an additional widget for term fields to create hierarchical selects.
Code
function shs_field_views_data_alter(&$result, &$field, $module) {
if (empty($field['columns']) || !in_array($field['type'], array(
'taxonomy_term_reference',
'entityreference',
))) {
return;
}
if ($field['type'] == 'entityreference' && (empty($field['settings']['target_type']) || $field['settings']['target_type'] != 'taxonomy_term')) {
// Do not change entityreference fields that do not reference terms.
return;
}
$field_column = key($field['columns']);
foreach ($result as $key => $group) {
$field_identifier = sprintf('%s_%s', $field['field_name'], $field_column);
if (empty($group[$field_identifier]) || empty($group[$field_identifier]['filter']['handler'])) {
// Only modify field definitions for the primary column.
continue;
}
// Replace handler.
$result[$key][$field_identifier]['filter']['handler'] = $field['type'] == 'entityreference' ? 'shs_handler_filter_entityreference' : 'shs_handler_filter_term_node_tid';
}
}