In function hook_views_data_alter (views.api.php) the use example code to change the handler of the title field is
$data['node']['title']['handler'] = 'modulename_handlers_field_node_title';

If I am not missing something, the code should be
$data['node']['title']['field']['handler'] = 'modulename_handlers_field_node_title';

to have any effect at all. It may be useful to review the entire set of examples, as it's probably the very starting point to learn how to override handlers.

#10 hook_views_data_alter-1946398-10.patch948 bytesbdgreen
PASSED: [[SimpleTest]]: [MySQL] 59,300 pass(es). View
#8 hook_views_data_alter-1946398-8.patch1.03 KBbdgreen
PASSED: [[SimpleTest]]: [MySQL] 59,341 pass(es). View


dawehner’s picture

Feel free to provide a patch.

pamatt’s picture

1.26 KB
PASSED: [[SimpleTest]]: [MySQL] 1,555 pass(es). View

Here it is. I also fixed a second similar error in the same hook declaration. I also changed some handler names for uniformity

pamatt’s picture

Status: Active » Needs review
pamatt’s picture

Status: Needs review » Active
pamatt’s picture

Status: Active » Needs review
dawehner’s picture

Project: Views » Drupal core
Version: 7.x-3.5 » 8.x-dev
Component: Code » views.module

Committed to 7.x-3.x. Thanks!

This patch can be in theory applied to Drupal 8.x as well.

dawehner’s picture

Priority: Normal » Minor
Status: Needs review » Patch (to be ported)


bdgreen’s picture

Issue summary: View changes
Status: Patch (to be ported) » Needs review
Issue tags: +LONDON_2013_DECEMBER
1.03 KB
PASSED: [[SimpleTest]]: [MySQL] 59,341 pass(es). View

Ported Patch to Drupal 8.x

dawehner’s picture

For drupal 8 this should look more like the following:

   $data['users']['example_field'] = array(
     'title' => t('Example field'),
     'help' => t('Some example content that references a user'),
-    'handler' => 'hook_handlers_field_example_field',
+    'field' => array(
+  	  'id' => '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';
+  $data['node']['title']['field']['id'] = 'node_title';
bdgreen’s picture

948 bytes
PASSED: [[SimpleTest]]: [MySQL] 59,300 pass(es). View

Thx Daniel. Revised patch attached.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +VDC

great, thank you!

webchick’s picture

Title: Uncorrect example in function hook_views_data_alter » Incorrect example in function hook_views_data_alter
Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.