Add option to limit calendar navigation (infinite pages!)

Created on 21 November 2019, over 5 years ago
Updated 7 February 2025, 3 months ago

Context:

Calendar (e.g. month) navigation always shows relative +/- 1 unit links like
calendar/month/201910 +1 or -1

Problem:

We found that crawlers follow these links to an infinite amount of pages.
For some sites it might be okay to have no limit, but for most you may want to "end" the calendar to stop crawlers from infinite crawling empty calendars.

Proposed solution:

Add an option to select a date range (absolute or relative) to show calendar navigation for
Add an option to set "rel=nofollow" on the Prev / Next links (which will not stop all crawlers but it may help).

Is there any workaround?

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany 4kant

    In Drupal 7 we could limit navigation this way:

    1. filter (limit) nodes by a relevant date field (e.g. < +14 days)
    2. 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.

  • Pipeline finished with Canceled
    3 months ago
    Total: 99s
    #418029
  • Pipeline finished with Failed
    3 months ago
    Total: 204s
    #418031
  • @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'),
            ],
          ];
    
Production build 0.71.5 2024