You are here

public function ViewsExcludePreviousNodes::query in Views exclude previous 8

Exclude all node's yet displayed.

Overrides InOperator::query

File

src/Plugin/views/filter/ViewsExcludePreviousNodes.php, line 54

Class

ViewsExcludePreviousNodes
Filter exclude previous viewed node's.

Namespace

Drupal\views_exclude_previous\Plugin\views\filter

Code

public function query() {
  $alias = $this->query
    ->ensureTable('node');
  if (!$alias) {
    return;
  }
  if (!$this->value) {
    return;
  }
  $excludes = [];
  foreach ($this->value as $category) {
    $excludes += _views_exclude_previous($category);
  }
  if (!empty($excludes)) {
    $this->query
      ->addWhere($this->options['group'], $alias . '.nid', $excludes, 'NOT IN');
  }
}