- Merge request !14Issue #3096023: Add option to limit calendar navigation (infinite pages!) → (Open) created by Unnamed author
- 🇩🇪Germany 4kant
In Drupal 7 we could limit navigation this way:
- filter (limit) nodes by a relevant date field (e.g. < +14 days)
- in navigation: choose "Page by Date" and check "Skip empty pages"
In Drupal 11 Filters work in lists etc., but not in calendars.
I haven't found a working filter in any calendar module yet. (Maybe someone can help me with this...) No changes are likely going to be made for Drupal 7, since that version of Drupal is no longer supported.
- 🇩🇪Germany 4kant
That wasn't my intention either.
I just wanted to show how the limitation could be implemented in Drupal 7.
I'm looking for help with Drupal 11. @anybody How would we modify the form elements to allow relative dates?
$form['date_range']['max_date'] = [ '#type' => 'date', '#title' => 'Enter Max date', '#format' => 'm/d/Y', '#description' => t('i.e. "09/06/2016" or "+1 year"'), '#default_value' => $this->options['date_range']['max_date'], '#attributes' => [ 'min' => \Drupal::service('date.formatter')->format(\Drupal::time()->getRequestTime(), 'custom', 'Y-m-d'), ], ]; $form['date_range']['min_date'] = [ '#type' => 'date', '#title' => 'Enter Min date', '#format' => 'd/m/Y', '#description' => t('i.e. "09/06/2016" or "-1 year"'), '#default_value' => $this->options['date_range']['min_date'], '#attributes' => [ 'max' => \Drupal::service('date.formatter')->format(\Drupal::time()->getRequestTime(), 'custom', 'Y-m-d'), ], ];