function hook_views_data_alter

Same name in other branches
  1. 7.x-3.x views.api.php \hook_views_data_alter()

Alter table structure.

You can add/edit/remove to existing tables defined by hook_views_data().

This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. This must either be in the same directory as the .module file or in a subdirectory named 'includes'.

The full documentation for this hook is in the advanced help. http://views-help.doc.logrus.com/help/views/api-tables

Related topics

4 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 modules/comment.views.inc
Use views_data_alter to add items to the node table that are relevant to comments.
taxonomy_views_data_alter in modules/taxonomy.views.inc
Implementation of hook_views_data_alter().
translation_views_data_alter in modules/translation.views.inc
Implementation of hook_views_data_alter().
upload_views_data_alter in modules/upload.views.inc
Implementation of hook_views_data_alter()
1 invocation of hook_views_data_alter()
_views_fetch_data in includes/cache.inc
Fetch Views' data from the cache

File

docs/docs.php, line 220

Code

function hook_views_data_alter(&$data) {
    // This example alters the title of the node: nid field for the admin.
    $data['node']['nid']['title'] = t('Node-Nid');
    // This example adds a example field to the users table
    $data['users']['example_field'] = array(
        'title' => t('Example field'),
        'help' => t('Some examüple 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';
}