You are here

function cshs_field_views_data_alter in Client-side Hierarchical Select 7

Implements hook_field_views_data_alter().

Taken from SHS - add the custom filter handler to taxonomy reference fields. Does not work together with SHS, as the handler is replaced and not added.

File

./cshs.module, line 60
A simple clientside hierarchical select widget for taxonomy terms.

Code

function cshs_field_views_data_alter(&$result, &$field, $module) {
  if (empty($field['columns']) || !in_array($field['type'], array(
    'taxonomy_term_reference',
  ))) {
    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'] = 'cshs_handler_filter_term_node_tid';
  }
}