Skip to content

Instantly share code, notes, and snippets.

@martsie
Created January 25, 2017 10:27
Show Gist options
  • Save martsie/05171347b09e57ee47a72885fe5beacf to your computer and use it in GitHub Desktop.
Save martsie/05171347b09e57ee47a72885fe5beacf to your computer and use it in GitHub Desktop.
Basic implementation of Drupal 7 hook_views_data()
<?php
/**
* Implements hook_views_data().
*/
function my_custom_module_views_data() {
$data['my_custom_module']['table']['group'] = t('My custom module');
$data['my_custom_module']['table']['join'] = array(
// Exist in all views.
'#global' => array(),
);
$data['my_custom_module']['my_custom_field'] = array(
'title' => t('My custom field'),
'help' => t('My custom field displays the word "Some custom markup".'),
'field' => array(
'handler' => 'views_handler_my_custom_field',
),
);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment