Join custom table in Views

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com我們的新網頁設計公司網頁.

<?php
function modulename_views_data() {
    $data = array();
    $data['modulename']['table']['group'] = t('modulename');
    $data['modulename']['table']['base'] = array(
    'field' => 'city_tid', 
    'title' => t('modulename table'), 
    'weight' => -10,
    );
 
    $data['modulename']['table']['join'] = array(
      'node' => array(
        'left_field' => 'nid',
        'field' => 'nid',
      ),
    );
 
    $data['modulename']['city_tid'] = array(
        'title' => t('modulename city ID'),
        'help' => t('modulename city ID.'),
        'relationship' => array(
          'base' => 'node',
          'field' => 'nid',
          'handler' => 'views_handler_relationship',
          'label' => t('Node id in this table that references a node.'),
        ),
        'filter' => array(
            'handler' => 'views_handler_filter',
        ),
        'field' => array(
            'handler' => 'views_handler_field',
            'click sortable' => TRUE,
        ),
        'sort' => array(
            'handler' => 'views_handler_sort',
        ),
        'argument' => array(
            'handler' => 'views_handler_argument',
        ),
    );
    return $data;
}
 
/**
* Implementation of hook_views_api().
*/
function modulename_views_api() {
 return array(
   'api' => 2,
   'path' => drupal_get_path('module', 'modulename'),
 );
}
?>
Help Share this Article