Add a custom handler method to a view? How can I add a custom handler method to a view ?

For example, i add a custom handler in hook_views_query_alter like this:

$this-&gt;view-&gt;addHandler('page_2', 'filter', 'node__field_subsidiary', 'field_subsidiary_type_value', [], 'custom_handler_subsidiary_type');


how I manage the handler logic?
Can you provide a little more information about what you are trying to do?

Regardless, you would need to create a subclass that extends views_handler_field (more info on that here https://api.drupal.org/api/views/handlers%21views_handler_field.inc/class/views_handler_field/7.x-3.x)

If you're trying to modify the output of an existing field, you would need to use a hook_views_data_alter (https://api.drupal.org/api/views/views.api.php/function/hook_views_data_alter/7.x-3.x) and change the handler specified in the $data array. Like so:

$data['table_name']['field_name']['field']['handler'] = 'hook_my_custom_handler_class_name';


This function hook should live in your module's hook.views.inc file within the 'views' folder in your module's root directory.

Your new handler class should be in a new file named the same as the class with .inc as the file type. That file should be added to your .info file using files[] = path_to_.inc_file

In your .module file, you would need to specify the views API:

function hook_views_api() {
  return array(
    'api' =&gt; 3,
    'path' =&gt; drupal_get_path('module', 'hook') . '/views',
  );
}


If you're still struggling, I found this video tutorial very useful https://www.youtube.com/watch?v=biKxw5iEzsY

I got caught out with spelling mistakes when doing this so check all your code!