0

I create a simple module to test hook_views_data but may I get some errors this is my code

in tungcan.module file

function test_views_api() {
  return array(
    'api' => '3'
  );
}

and in tungcan.views.inc file

function tungcan_views_data() {
  $data = array();
  $data['tungcan']['table']['group'] = t('TungCan');
  $data['tungcan']['table']['basic'] = array(
    'field' => 'tungid',
    'title' => t('Tungcan'),
    'weight' => -100,
    'defaults' => array(
      'field' => 'tungname',
    ),
  );

  $data['tungcan']['tungname'] = array(
    'title' => t('Tung Name'),
    'help' => t('Display name of Tung')
  );

  return $data;
}

but when I clear cache, in my Views (add new views or add new Field) doesn't change anything.

Can somebody point out what is wrong in my code?

1 Answer 1

3

If the module is tungcan.module, then the implementation of hook_views_api() (necessary to load the include files used from the module to integrate with the Views module) should be tungcan_views_api(), not test_views_api().

If, vice versa, the module is test.module, then tungcan_views_data() should be renamed to test_views_data().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.