Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
linenumberstrue
/**
 * @file
 * Views definitions for 'example'
 */

/**
 * Implementation of hook_views_handlers() to register all of the basic handlers
 * views uses.
 */
function example_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'example'),
    ),
    'handlers' => array(
      // The name of my handler
      'example_handler_custom_field' => array(
        // The name of the handler we are extending.
        'parent' => 'views_handler_field',
      ),
    ),
  );
}

/**
 * Implements hook_views_data().
 */
function example_views_data() {
  $data = array();
  // Add Example group
  $data['example']['table']['group'] = t('Example');
  $data['example']['table']['join'] = array(
    // #global is a special flag which let's a table appear all the time.
    '#global' => array(),
  );
  // Add custom field
  $data['example']['custom_field'] = array(
    'title' => t('Custom Field'),
    'help' => t('Provides a custom field.'),
    'field' => array(
      'handler' => 'example_handler_custom_field',
    ),
  );
  return $data;
}

...