Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Step 1) Create module info file " mymodule_views_table.info ".

name = mymodule_views_table
description = Create external table view.
package = Custom Drupal 7 Development
core = 7.x

Step 2) Create module file " mymodule_views_table.module ".

    function mymodule_views_table_views_api(){ // Register view API information
        $view = array();
        $view = array('api'=>3,
        'path'=>drupa_get_path('module','mymodule_views_table')                
        );
        return $view;
    }


    function mymodule_views_table_views_data(){ //Describes data tables
        $table = array();
        
        $table['custom table']['table']['group'] => t('custom table');
        $table['custom table']['table']['base'] =>array(
                'title'=>t('Courses'), //Courses is Custom external table
                'field'=>'id',
                'help'=>t('Contains courses, departments, and descriptions')); 
                
                
        $table['custom table']['title']=>array(
                'title'=>t('Course name'), //Custom external table field
                'help'=>t('Course name'),
                'field'=> array(
                    'handler'=> 'views_handler_field',
                    'click sortable'=> TRUE,),
                'sort'=>array(handler=>'views_handler_sort',),
                'filter'=>array(handler=>'views_handler_filter_string',),
                'argument'=>array(handler=>'views_handler_argument_string',),  
        );
    
        $table['custom table']['Department']=>array(
                'title'=>t('Department'), //Custom external table field
                'help'=>t('Department name'),
                'field'=>array(
                    'handler'=>'views_handler_field',
                    'click sortable'=>TRUE,),
                'sort'=>array('handler'=>'views_handler_sort',),
                'filter'=>array('handler'=>'views_handler_filter_string',),
                'argument'=>array('handler'=>'views_handler_argument_string'),      
        
        );
        
        
        $table['custom table']['Description']=>array(
                'title'=>t('description'), //Custom external table field
                'help'=>t('description name'),
                'field'=>array('handler'=>'views_handler_field',
                'click  sortable'=>TRUE,),
                'sort'=>array('handler'=>'views_handler_field'),
                'filter'=>array('handler'=>'views_handler_filter_string',),
                'argument'=>array('handler'=>'views_handler_argument_string',),
         
        );
        
        
        $table['custom table']['id'] = array(
                'title' => t('Unique identifier'), //Custom external table field
                'help' => t('Primary key for table'),
                'field' => array('handler' => 'views_handler_field'),
                'argument' => array('handler' => 'views_handler_argument_numeric'),
                'filter' => array('handler' => 'views_handler_filter_numeric'),
                'sort' => array('handler' => 'views_handler_sort_numeric'));
                
    return $table;
    
    }

Thanks:
Mtoag Technologies
mtoag.com

Project information

  • Created by Mtoag on , updated