You are here

function languagefield_field_views_data_alter in Custom Language field 7

Implements hook_field_views_data_alter().

File

./languagefield.views.inc, line 260
languagefield.views.inc

Code

function languagefield_field_views_data_alter(&$result, &$field, &$module) {

  // This is a fix for languagefield module.
  if ($field['type'] == 'language_field') {
    $field_name = $field['field_name'] . '_value';
    foreach ($result as &$table_name) {
      if (isset($table_name[$field_name])) {
        if (isset($table_name[$field_name]['filter'])) {
          $table_name[$field_name]['filter']['handler'] = 'languagefield_handler_filter_locale_language';
        }
        $table_name[$field_name]['relationship'] = array(
          'handler' => 'views_handler_relationship',
          'base' => 'languages',
          'base field' => 'language',
          'label' => t('Language from !field_name', array(
            '!field_name' => $field['field_name'],
          )),
          'help' => t('Provides access to all of the language properties.'),
          'languages' => array(
            'field' => $field['field_name'],
          ),
        );
      }
    }
  }
}