Group and fields from custom module does not appear in Views

Events happening in the community are now at Drupal community events on www.drupal.org.
themusician's picture

Hi,

I have been trying to implement a custom module that can use views to display data from a remote database. I have successfully created a module and enabled it, however I cannot access my data through views. This is using Drupal 6.2 and Views 2.12.

Here is what I have done:

I created a custom module called displayjobs and stored it in /sites/all/modules. This directory contains displayjobs.info, displayjobs.module, and displayjobs.views.inc.

In sites/default/settings.php I have added another connection string for my remote database and have successfully returned queries through a php script embedded in a node.

displayjobs.module contains the following except for the closing php tag:

<?php
/**
* Implementation of hook_views_api().
*
* This tells drupal that there is Views integration file named
* module-name.views.inc
*/

function displayjobs_views_api() {
  return array(
   
'api' => 2.0
 
);
}
?>

The database that I am connected to on the remote machine is named JOBS and through the settings.php I have identified to drupal as jobs. It contains a table named requisition. Here is the contents of displayjobs.views.inc minus the closing php tag.

<?php
/*
* Provide views data for displayjobs.module
* Implementation of hook_views_data()
*/

function displayjobs_views_data() {
 
$data = array();
      
//Create a group to use in Views when selecting relationships, arguments, fields, sort criteria, and filters
//basic table information

       
$data['requisition']['table']['group'] = t('Jobs');

//Define the primary key in the table Requisition
       
$data['requisition']['table']['base'] = array(
               
'field' => 'requisition_id',
               
'title' => t('Requisition Table'),
               
'help' => t("The Requisition Table holds job numbers."),
               
'weight' => -10,
               
'database' => 'jobs',
        );

    
$data['requisition']['requisition_id'] = array(
           
'title' => t('Requisition ID'),
        
'help' => t("This is the Primary Key for the Requisition Table."),
         
'field' => array(
               
'handler' => 'views_handler_field',
            
'click sortable' => TRUE,
         ),
     );

//FTE for jobs
       
$data['requisition']['fte'] = array(
               
'title' => t('FTE'),
               
'help' => t("FTE Amount"),
             
'field' => array(
                
'handler' => 'views_handler_field_numeric',
                
'click sortable' => TRUE,
             ),
        );

        return
$data;
}
?>

Now, when I go to Views in the backend I click fields to add the field FTE but no group Jobs appears and no FTE field. I have cleared the Views Cache and the Drupal cache. This is my first time with a custom implementation of views but I do not see where I have gone wrong. Any help would be much appreciated.

Thank you.

Comments

The only thing i could guess

dawehner's picture

The only thing i could guess is that you use the wrong view type, for example node instead of Requisition

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: