function views_field_add_multi_join in Views Field 7
Adds a multi-column join definition between two field tables.
The join uses the primary key columns.
In Views, a join is from a source table (which may also be a base table) to a base table. The join automatically makes the fields of the source table available on a view built from the base table.
Parameters
array $data: The views data definition.
string $base_field: Together with $base_type, this defines the base table whose data definition is to be modified.
string $join_field: Together with $base_type, this defines the table to join the base table to. Note: when called by field_group_views, this should be the primary field.
string $base_type: The prefix applied to $base_field and $join_field to determine the base and join tables. Allowed values are 'field_data' and 'field_revision.'
File
- ./
views_field.inc, line 348 - Modifies definitions of base tables, fields, and joins for views.
Code
function views_field_add_multi_join(&$data, $base_field, $join_field, $base_type = 'field_data') {
if ($base_type != 'field_data' && $base_type != 'field_revision') {
return;
}
$base_table = $base_type . '_' . $base_field;
$join_table = $base_type . '_' . $join_field;
if (!isset($data[$base_table])) {
return;
}
// The primary key columns of a field table.
$fields = drupal_map_assoc(array(
'entity_type',
'entity_id',
'revision_id',
'deleted',
'delta',
'language',
));
if ($base_type == 'field_data' || !isset($data[$base_table]['revision_id'])) {
unset($fields['revision_id']);
}
// Define the join.
$data[$base_table]['table']['join'][$join_table] = array(
'handler' => 'views_field_join',
'left_field' => $fields,
'field' => $fields,
'type' => 'INNER',
'extra' => array(
array(
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
),
),
);
// Only expose the join definition to alteration.
$context = array(
'base_field' => $base_field,
'join_field' => $join_field,
'base_type' => $base_type,
);
drupal_alter('views_field_add_multi_join', $data[$base_table]['table']['join'][$join_table], $context);
}