Question about pagination and filters

Created on 13 August 2023, over 1 year ago
Updated 17 August 2024, 6 months ago

Problem/Motivation

In this issue ✨ Add filter to query to allow paging even for large calendars Fixed , a patch is adding a query function to CalendarViewMonth.
This code isn't in the current version.

This commit changes the query() function to getRowValues().

My question is whether this can still modify the view query, or if filters can still be set up another way to do so. It appears that without this code, the view does a full query for all items and then filters them out in the display.

If I patch the query function back in, I can see the views query get a where clause for the date field range.

Steps to reproduce

Create a calendar month view with month pager. Using the pager in the views UI does not change the query without patching this code back in.

Proposed resolution

Discuss how filters work with the pager.

πŸ’¬ Support request
Status

Closed: works as designed

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

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

Comments & Activities

  • Issue created by @mortona2k
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta

    I just stumbled across the same issue, and discovered the solution. The commit you pointed to @mortona2k changed the way the base style plugin works, so that now it assumes you will add two date offset filters to your View. The style plugin will then automatically modify those filters to adjust the offset based on the current state of the calendar.

    So for example, I have a calendar by month. I needed to add two filters to my View:

    1. Filter by timestamp with an "offset" greater than or equal to "-1 month".
    2. Filter by timestamp with an "offset" less than or equal to "+1 month".

    This serves to load all entities in the current month, as well as entities in the previous and next months. It's important to load 3 months like this, because sometimes the current month view shows a few days of last/next month at the beginning/end.

    This is documented on the project page, but I didn't notice that at first. Maybe it could be improved. It also links to https://www.drupal.org/docs/contributed-modules/calendar-view/recurring-... β†’ , which is specifically for "recurring events", which I do not have, so I found that confusing and wasn't sure if it was relevant to me at first.

    Hope this helps someone else!

  • Status changed to Closed: works as designed 6 months ago
  • Thank you for opening this issue @mortona2k.

    There was indeed an attempt to filter the calendar view at the View's query level with the query() method but it was very tricky and prompt to errors - in particular in combination with smart_date module and other date fields provided by other modules - with the table name and/or suffix (e.g. missing or extra suffix _value...etc).

    After many trials, I decided to remove the filtering with query(). The site builder is in charge of building a sustainable View (i.e. do not try to load thousands of recurring events 😱).

    There is a documentation page about setting the filters with an offset value such as -1 month and +1 month.

    I hope it is clear now. Let me know if I can help explaining more architectural decisions.

Production build 0.71.5 2024