Details
-
Type: Patch
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.1.4, 2.2.0
-
Fix Version/s: 2.2.0
-
Component/s: Drupal Integration Modules
-
Labels:None
Description
Added relationship tables integration for View 2 module using wonderful code by James Rakich as a guide.
Still cannot get Relationship custom fields to import in the same nice way as it is done for Contacts, Contributions and so on.
Tested on 2.1.4.
Exported view for testing:
$view = new view;
$view->name = 'civicrm_relationship_simple';
$view->description = '';
$view->tag = 'civicrm';
$view->view_php = '';
$view->base_table = 'civicrm_relationship';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'contact_id_a' => array(
'label' => 'CiviCRM Contact A',
'required' => 0,
'id' => 'contact_id_a',
'table' => 'civicrm_relationship',
'field' => 'contact_id_a',
'relationship' => 'none',
),
'contact_id_b' => array(
'label' => 'CiviCRM Contact B',
'required' => 0,
'id' => 'contact_id_b',
'table' => 'civicrm_relationship',
'field' => 'contact_id_b',
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'id' => array(
'label' => 'Relationship ID',
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'exclude' => 0,
'id' => 'id',
'table' => 'civicrm_relationship',
'field' => 'id',
'relationship' => 'none',
),
'display_name' => array(
'label' => 'Display Name',
'link_to_civicrm_contact' => 1,
'exclude' => 0,
'id' => 'display_name',
'table' => 'civicrm_contact',
'field' => 'display_name',
'relationship' => 'contact_id_a',
),
'display_name_1' => array(
'label' => 'Display Name B',
'link_to_civicrm_contact' => 1,
'exclude' => 0,
'id' => 'display_name_1',
'table' => 'civicrm_contact',
'field' => 'display_name',
'relationship' => 'contact_id_b',
),
'description' => array(
'label' => 'Description',
'exclude' => 0,
'id' => 'description',
'table' => 'civicrm_relationship',
'field' => 'description',
'relationship' => 'none',
),
'end_date' => array(
'label' => 'End Date',
'date_format' => 'custom',
'custom_date_format' => 'Y M',
'exclude' => 0,
'id' => 'end_date',
'table' => 'civicrm_relationship',
'field' => 'end_date',
'relationship' => 'none',
),
'is_active' => array(
'label' => 'Is Relationship Active',
'type' => 'yes-no',
'not' => 0,
'exclude' => 0,
'id' => 'is_active',
'table' => 'civicrm_relationship',
'field' => 'is_active',
'relationship' => 'none',
),
'start_date' => array(
'label' => 'Start Date',
'date_format' => 'custom',
'custom_date_format' => 'Y M',
'exclude' => 0,
'id' => 'start_date',
'table' => 'civicrm_relationship',
'field' => 'start_date',
'relationship' => 'none',
),
'text_link' => array(
'label' => 'Text Link',
'link_to_civicrm_relationship' => 'view_A_B',
'custom_link' => '',
'link_text' => 'view a_b',
'exclude' => 0,
'id' => 'text_link',
'table' => 'civicrm_relationship',
'field' => 'text_link',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'text_link_1' => array(
'label' => 'Text Link',
'link_to_civicrm_relationship' => 'edit_B_A',
'custom_link' => '',
'link_text' => 'edit b_a',
'exclude' => 0,
'id' => 'text_link_1',
'table' => 'civicrm_relationship',
'field' => 'text_link',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'relationship_type' => array(
'id' => 'relationship_type',
'table' => 'civicrm_relationship',
'field' => 'relationship_type',
'relationship' => 'none',
'operator' => 'in',
'value' => array(
'4' => '4',
),
),
));
$handler->override_option('access', array(
'type' => 'role',
'role' => array(
'4' => 4,
'3' => 3,
),
));
$handler->override_option('items_per_page', 30);
$handler->override_option('use_pager', '1');
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'who_works_where');
$handler->override_option('menu', array(
'type' => 'normal',
'title' => 'Who works where',
'weight' => '40',
'name' => 'menu-views-collection',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));