[development] Views field handler being ignored

jeff at ayendesigns.com jeff at ayendesigns.com
Mon Oct 18 04:09:05 UTC 2010


Realized I was missing a hook, but adding it hasn't helped. I'm going to 
paste the code here, since it's short.

sites/all/modules/my/my.info

; $Id:
name = Test Handler
description = Overrides a view handler
package = My modules
files[] = my.module
files[] = my_views.inc
files[] = my_handler_field_node.inc
version = "7.x-1.0"
core = "7.x"
php = 5.2

sites/all/modules/my/my.module

<?php
/**
  * Implements hook_views_handlers().
  */
function my_views_handlers() {
   return array(
       'my_handler_field_node');
}

/**
  * Implements hook_views_api().
  */
function my_views_api() {
   return array(
     'api' => 2,
   );
}


sites/all/modules/my/my.views.inc


/**
  * Implements hook_views_data_alter()
  */
function my_views_data_alter(&$data) {
   $data['node']['title']['field']['handler'] = 'my_handler_field_node';

   return $data;
}

/**
  * Implements hook_views_handlers() to register all of the basic handlers
  * views uses.
  */
function my_views_handlers() {
   return array(
     'handlers' => array(
       'my_handler_field_node' => array(
         'parent' => 'views_handler_field_node',
       ),
     ),
   );
}

sites/all/modules/my/my_handler_field_node.inc

class my_handler_field_node extends views_handler_field {

   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
     $form['link_to_node'] = array(
       '#title' => t('Link this field to its node'),
       '#description' => t('This is different text.'),
       '#type' => 'checkbox',
       '#default_value' => !empty($this->options['link_to_node']),
     );
   }



More information about the development mailing list