You are here

Views join handlers in Views (for Drupal 7) 8.3

Handlers to tell Views how to join tables together.

Here is an example how to join from table one to example two so it produces the following sql:


INNER JOIN {two} ON one.field_a = two.field_b
@code.
The required php code for this kind of functionality is the following:
@code
$configuration = array(
  'table' => 'two',
  'field' => 'field_b',
  'left_table' => 'one',
  'left_field' => 'field_a',
  'operator' => '='
);
$join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $configuration);

Here is how you do complex joins:

@code
class JoinComplex extends JoinPluginBase {
  public function buildJoin($select_query, $table, $view_query) {
    // Add an additional hardcoded condition to the query.
    $this->extra = 'foo.bar = baz.boing';
    parent::buildJoin($select_query, $table, $view_query);
  }
}

File

lib/Drupal/views/Plugin/views/join/JoinPluginBase.php, line 12
Definition of Drupal\views\Plugin\views\join\JoinPluginBase.

Classes

Namesort descending Location Description
JoinPluginBase lib/Drupal/views/Plugin/views/join/JoinPluginBase.php Represents a join and creates the SQL necessary to implement the join.