Oh. Views He took me at the same time. This answer is for Drupal 6, and in the abstract shows how to define fields and also use a relationship so that the fields can refer to the node table.
Inside modulename.module you need a function that goes:
function modulename_views_api() {
return array(
'api' => 2,
);
}
Then you want to create a file called modulename.views.inc and define a function like this:
function modulename_views_data () {
$ data ['modulename_table'] = array (
'table' => array (
'group' => 'ModuleName',
'title' => 'Module name title',
),
'join' => array (
// to join to node, we'll use a field in modulename_table called 'nid'
'node' => array (
'left_field' => 'nid',
'field' => 'nid',
),
),
);
// now we define the fields in the table like this
// check out modules/views/handlers to see more specific handlers
$data['modulename_table']['fieldname'] = array(
'title' => 'fieldname',
'help' => 'fieldname description',
'field' => array(
'handler' => 'views_handler_field',
),
);
$data['modulename_table']['nid'] = array(
'title' => 'related node',
'help' => 'the field that relates back to {node}',
// here we implement a relationship to nid
'relationship' => array(
'base' => 'node',
'field' => 'nid',
'handler' => 'views_handler_relationship',
'label' => 'modulename row node',
),
// this relationship can be turned on in views
);
return $data;
}