By editor, 15 April, 2016 Question How to use Drupal Views with a custom table ? Using hook_views_data() and hook_views_data_alter() How tu use multiple database conncetion with views_data() ? Officiel Documentation : https://api.drupal.org/api/drupal/core!modules!views!views.api.php/function/hook_views_data/8 Use multiple database conncetion with views_data() For that you must add 'database' Example: $data['mydatabasetable']['table']['base'] = array( .... 'database' => 'mydatabase', ); If you join databases: Change 'name', 'base' and 'join' () $data['mydatabasetable']['table']['name'] = 'mydatabase' . '.fieldname'; $data['mydatabasetable']['table']['base']['database'] = 'mydatabase'; $data['mydatabasetable']['table']['join']['myseconddatatable']['table'] = 'mydatabase' . '.fieldname', Like: //Other Database name : mydatabase. $db_name = 'mydatabase'; $data['fieldname'] = array( 'table' => array( 'name' => $db_name . '.fieldname', 'group' => t('The Group'), 'base' => array( 'field' => 'id', 'title' => t('The field title'), 'help' => t('Field description'), 'database' => $db_name, ), 'join' => array( 'users' => array( 'table' => $db_name . '.fieldname', 'left_field' => 'id', 'field' => 'id2', ), ), ), ); Follow the tutorial Use multiple databases. Tags Drupal 8 Code Views Hook Add new comment Use multiple / external databases in Drupal 8 Create a simple module to use Drupal 8 Hook System Create a View Plugin Without using Database field Custom Views Data handler for a custom Entity on drupal 8 Comments1 You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically. not working doesn't work for me when follwing this approach and including a relationthip in one field 'relationship' => array( ... 'base' => 'mydefaultdb' . '.users_field_data', 'base field' => 'uid', 'field' => 'uid', ), Reply
not working doesn't work for me when follwing this approach and including a relationthip in one field 'relationship' => array( ... 'base' => 'mydefaultdb' . '.users_field_data', 'base field' => 'uid', 'field' => 'uid', ), Reply
Comments1
not working
doesn't work for me when follwing this approach and including a relationthip in one field
'relationship' => array(
...
'base' => 'mydefaultdb' . '.users_field_data',
'base field' => 'uid',
'field' => 'uid',
),