1

I get date with contextual filter in views and i want set "greater than" my date. This option not exist in contextual filter. I cannot use argument in filter criteria.

In drupal 7 we can use "2017-01-01--2017-12-18" for range date with contextual filter, but in drupal 8, this trick not work.

Someone can help me, with date and contextual filter ?

Thank you

1 Answer 1

1

I don't understand why we don't have operator (>=, <=, etc.) in contextual filter...

Temporary solution... affect all views with argument :

File :

\core\modules\views\src\Plugin\views\argument\Formula.php

Change :

$formula = $this->getFormula() . ' = ' . $placeholder; 

to

$formula = $this->getFormula() . ' >= ' . $placeholder; 

Function :

public function query($group_by = FALSE) {
    $this->ensureMyTable();
    // Now that our table is secure, get our formula.
    $placeholder = $this->placeholder();
    $formula = $this->getFormula() . ' >= ' . $placeholder; 
    $placeholders = [
      $placeholder => $this->argument,
    ];
    $this->query->addWhere(0, $formula, $placeholders, 'formula');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.