1

I have gone through tons of reading... I even went into drupal archivess looking for help :(

I have defined my own content types and fields as well as my own db tables. I want to be able to display these fields using views module in drupal 6.

This is the coding I have done so far:

function svm_mail_views_tables() {
  //Define the groups table
  $table['svm_mail_groups'] = array(
      'name' => 'svm_mail_groups',
      'join' => array(
          'left' => array(
              'table' => 'node',
              'field' => 'nid',
              ),
          'right' => array(
              'field' => 'nid',
              ),
          ),
      'fields' => array(
          'group_id' => array(
              'name' => t('SVM: Group ID'),
              'help' => t('The group id'),
              'sortable' => TRUE,
              ),
          ),
      'sorts' => array(
          'group_id' => array(
              'name' => t('Group ID'),
              'help' => t('The Group ID')
              ),
          ),
      );
  return $table;
}

I still don't have this available in my views module when building a view.

Can anyone help me out here and tell where I'm going wrong?

Thanks in advance.

2 Answers 2

2

If you want to add custom database tables in a view, you need to let views know about it by invoking hook_views_data() http://blog.menhir.be/2008/10/22/expose-database-fields-to-views-in-a-custom-drupal-module/

There is also documentation for this within the views module.

It looks like you are on the right track but your function name is _tables() instead of _data().

0
0

As acouch pointed out, you need to implement hook_views_data(). The Drupal API documentation has a good example, as well as the Drupal 6 views online help.

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.