Search code examples
drupaldrupal-7drupal-views

hook_views_handlers is not getting called


My hook_views_handlers() is not getting called. I've tried clearing cache, re-installing the module, etc... I've added watchdog() calls to see if it gets called, and it never does.

This field exposes a counter with the same type of code views counter uses:

I can add the field to the view, but once I add it, it just shows as "Broken/Missing"

All 3 of these files are in the root of the funwithviews module directory. Here is the relavent code.

Does anything look out of place?

This exists in: funwithviews.module

/**
 * Implements hook_views_api().
 */
function funwithviews_views_api() {
  return array(
    'api' => 3.0
  );
}

This exists in: funwithviews.views.inc

/**
 * Implementation of hook_views_data()
 */
function funwithviews_views_data() {
  $data['fwv']['table']['group'] = t('FunSpace');
  $data['fwv']['table']['join'] = array(
    '#global' => array(),
  );
  $data['fwv']['counter'] = array(
    'title' => t('Fun counter'),
    'help' => t('This counter is more fun than the other one.'),
    'field' => array(
      'handler' => 'funwithviews_handler_field_fwv_counter',
    ),
  );
  return $data;
}

/**
 * Implements of hook_views_handlers().
 */
function funwithviews_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'funwithviews'),
    ),
    'handlers' => array(
      'funwithviews_handler_field_fwv_counter' => array(
        'parent' => 'views_handler_field',
      ),
    ),
  );
}

This exists in: funwithviews_handler_field_fwv_counter.inc

class funwithviews_handler_field_fwv_counter extends views_handler_field {

Solution

  • Yes you have to add it to your info file i think as demonstrated by views itself: http://drupalcode.org/project/views.git/blob/refs/heads/7.x-3.x:/views.info