Some tips and tricks for integrating Views2 and CiviCRM
- If your CiviCRM install uses a different database to your Drupal install, ensure that your Drupal DB user has SELECT rights to your CiviCRM DB. Some hosting platforms might make this difficult. For more information about setting up Drupal multi-database access: http://drupal.org/node/18429
- You will need to set database prefixes in your Drupal settings.php file so that Views2 can access your CiviCRM DB. The prefixes can be seen on a url like: http://drupal.demo.civicrm.org/civicrm/admin/setting/uf?reset=1. You will need to have Views2 enabled to see those settings. Important: You will have to update your settings.php with new prefixes every time you add new Custom Field Group. Also, after making changes in civicrm you should clear Drupal's view cache at: Administer › Site building › Views › Tools and press "Clear Views cache".
- If you have CiviCRM and Drupal installed on the same database, and drupal tables are prefixed, you might receive an error in your views saying table does not exist, if this happens, you need to alter your drupal sites/default/settings.php file. find the part that says $db_prefix = 'drupal_'; and change it to this: $db_prefix = array ('default'=>'drupal_','civicrm_event'=>'','civicrm_activity'=>'','civicrm_contact'=>'','civicrm_address'=>'','civicrm_contribution'=>''); NOTE: your prefix may be something other then drupal_, just replace drupal_ with whatever prefix you have configured.
- If the above steps dont work for you or your drupal/civicrm db's have a different user name/password, try this recipe from andrew: CiviCRM Views 2 integration with a remote CiviCRM database
- A diagram from the work done by James Rakich
Diagram for civicrm_relationship table: