function hook_views_data_alter

Alter the table structure defined by hook_views_data().

Parameters

array $data: An array of all Views data, passed by reference. See hook_views_data() for structure.

See also

hook_views_data()

Related topics

10 functions implement hook_views_data_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

comment_views_data_alter in drupal/core/modules/comment/comment.views.inc
Implements hook_views_data_alter().
contextual_views_data_alter in drupal/core/modules/contextual/contextual.views.inc
Implements hook_views_data_alter().
field_views_data_alter in drupal/core/modules/field/field.views.inc
Implements hook_views_data_alter().
file_field_views_data_views_data_alter in drupal/core/modules/file/file.views.inc
Implements hook_field_views_data_views_data_alter().
image_field_views_data_views_data_alter in drupal/core/modules/image/image.views.inc
Implements hook_field_views_data_views_data_alter().

... See full list

1 invocation of hook_views_data_alter()
ViewsData::getData in drupal/core/modules/views/lib/Drupal/views/ViewsData.php
Gets all data invoked by hook_views_data().

File

drupal/core/modules/views/views.api.php, line 269
Describes hooks and plugins provided by the Views module.

Code

function hook_views_data_alter(array &$data) {

  // This example alters the title of the node:nid field in the Views UI.
  $data['node']['nid']['title'] = t('Node-Nid');

  // This example adds an example field to the users table.
  $data['users']['example_field'] = array(
    'title' => t('Example field'),
    'help' => t('Some example content that references a user'),
    'handler' => 'hook_handlers_field_example_field',
  );

  // This example changes the handler of the node title field.
  // In this handler you could do stuff, like preview of the node when clicking
  // the node title.
  $data['node']['title']['handler'] = 'modulename_handlers_field_node_title';

  // This example adds a relationship to table {foo}, so that 'foo' views can
  // add this table using a relationship. Because we don't want to write over
  // the primary key field definition for the {foo}.fid field, we use a dummy
  // field name as the key.
  $data['foo']['dummy_name'] = array(
    'title' => t('Example relationship'),
    'help' => t('Example help'),
    'relationship' => array(
      'base' => 'example_table',
      // Table we're joining to.
      'base field' => 'eid',
      // Field on the joined table.
      'field' => 'fid',
      // Real field name on the 'foo' table.
      'id' => 'standard',
      'label' => t('Default label for relationship'),
      'title' => t('Title seen when adding relationship'),
      'help' => t('More information about relationship.'),
    ),
  );

  // Note that the $data array is not returned – it is modified by reference.
}