Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I created a calendar view with a block display, and I enabled ajax mode. But the pager didn't work because view_args always contained the current date (instead of next/prev date) in the ajax request.
I think I fixed it, I'll attach my patch file soon.
Comment | File | Size | Author |
---|---|---|---|
#37 | calendar-view_args_ajax_fix-2858086-37.patch | 1.29 KB | mreda |
#35 | calendar-view_args_ajax_fix-2858086-35.patch | 976 bytes | arijits.drush |
#34 | calendar-view_args_ajax_fix-2858086-34.patch | 915 bytes | Flodevelop |
#31 | view_args_ajax_fix-2858086-5-31.patch | 1.09 KB | Foxy-vikvik |
#26 | calendarissueajax.png | 72.2 KB | nicxvan |
Issue fork calendar-2858086
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lonaloreComment #3
StryKaizerWhile this patch does fix the ajax pagination for months, it also adds a GET parameter on month view pages which do not use ajax, resulting in urls like this:
/my_month_view/201705?view_args=201705
Comment #4
lonaloreThank you! I fixed it.
Comment #5
recidive CreditAttribution: recidive commentedRe-rolling patch in #4.
Comment #6
interdruper CreditAttribution: interdruper at Interdruper commented#4/#5 work like a charm. Thanks.
Comment #7
shaktik#4/#5 working fine!
Thanks.
Comment #8
johnsiciliI believe this patch is conflicting with another one recently accepted:
https://www.drupal.org/project/calendar/issues/2810739
I have an updated patch that I plan on uploading once I spend a little more time with it.
Comment #9
johnsiciliThis patch seems to be working for me. I removed
if ($this->view->ajaxEnabled())
and its still working with ajax enabled on the view. Let me know what you guys think.Comment #10
johnsiciliComment #11
icurk CreditAttribution: icurk commented@johnsicili I tested your patch, but it didn't work for me. There were missing view_args in links. Here is a patch that worked for me.
Comment #12
johnsicili@icurk, several months later and I also notice an issue with my patch. Applied yours in #11 and works great, thanks.
+1 RTBC
Comment #13
johnsiciliComment #14
solide-echt CreditAttribution: solide-echt commentedI just re-checked this and cannot reproduce it. There have been multiple improvements in views from core to handle ajax paging in blocks; similar issues have been reported for e.g. faceted search. Are we sure this issue still exists?
Comment #15
joelpittetLooking for a reply to #14
Comment #16
arijits.drushComment #17
vlad.dancerI'm upgrading client's project from D8 to D9 and previously we've used lots of patches for the calendar module.
I've checked them and @solide-echt is right about
and also this module received lots of patches since 2018.
But unfortunately ajax issues is still here.
We have a calendar block with enabled ajax and pager links don't work without setting
view_args
.Below is an updated patch to fix the problem.
Additionaly I've changed function's return type and value to be consistent.
I think Url object if more universal because someone could want to alter let's say an url access, etc.
The only palce where pager links are used is
calendar-pager.html.twig
.So there shouldn't be any problems with sending Url object.
Comment #18
akalam CreditAttribution: akalam commentedPatch #17 is working for me.
Comment #19
jillh68 CreditAttribution: jillh68 commentedThe error I was receiving was: Error: Call to a member function setOption() on string in Drupal\calendar\Plugin\views\pager\CalendarPager->getPagerUrl(). Patch #17 fixed the issue.
Comment #20
arijits.drushIf views calendar Ajax is enabled, and produced within a Block an that block got integrated within a Panels page and panels page also have some parameter within it, then no patch is not providing desired result.
The reason is
creating route from view rather than calculating parent page route
Comment #21
ram4nd CreditAttribution: ram4nd as a volunteer commentedPatch #20 worked for me correctly.
Comment #22
joelpittetThis one needs a reroll, and it's tricky to understand the steps to reproduce, can anybody boil it down so I can test it out? Does panels need to be involved?
Comment #24
nicxvan CreditAttribution: nicxvan commented@joelpittet, I'll reroll this on an issue fork. The issue is when calendar is called via ajax the arguments don't get passed to the view. Panels isn't required.
Comment #26
nicxvan CreditAttribution: nicxvan commentedOk I've updated this, it works for me without changing the return type from a string. I think the pager can handle a string or a url object and since we previously returned a string I kept it that way, we just moved the toString to the return statement.
I've added a screenshot to show the situation this occurs in.
There is a calendar modal.
When the patch is not applied, if I click next I get the ajax spinnner the modal refreshes and it's still on August no matter how many times I press it.
When the patch is applied, when I click next I get September as expected. Sometimes it takes two clicks to start changing, I think there is something on my preprocess not setting the default argument correctly so it's not a bug in this patch.
Comment #27
nicxvan CreditAttribution: nicxvan commentedComment #28
joseph.olstadrerolled in the merge request
Comment #29
joelpittetI'm a bit torn on this and why it works...
Because the same thing looks to be done here already:
Which makes me think that this is a core Views bug and we might be shooting ourselves in the foot by fixing it here.
Comment #30
Foxy-vikvik CreditAttribution: Foxy-vikvik at DevBranch, Drupal Ukraine Community, Evolving Web commentedRe-used #5 patch.
Works fine with php 8.0.27 Drupal v 9.5.10
Comment #31
Foxy-vikvik CreditAttribution: Foxy-vikvik at DevBranch, Drupal Ukraine Community, Evolving Web commentedSuccessfully resolved issue 30 with the implementation of patch 31.
Comment #32
nicxvan CreditAttribution: nicxvan commented@Foxy-vikvik, why did you change how the return value works?
Is it just to get the base path included?
Are you able to contribute using the issue fork rather than a separate patch?
Comment #33
nicxvan CreditAttribution: nicxvan commentedI have a few further questions / comments on the patch in comment 31.
1. Why are you setting query to input instead of just using the input variable? I'm not sure it's more clear.
2. The work you do in the ajax is enabled check duplicates what you do in the url each time, e.g. you're imploding in the check then again in the return
3. I'm still not clear why toString was not sufficient
Is there an additional use case you were hitting that the current patch didn't work for that we can address in the issue fork?
Comment #34
Flodevelop CreditAttribution: Flodevelop commentedHello,
I update the patch from #17 on my Drupal 9.5 + Calendar Beta 1 and the ajax pager in my views block is working fine.
Comment #35
arijits.drushFor 8.x-1.x
Comment #36
nicxvan CreditAttribution: nicxvan commentedPlease use the MR for contribution.
Comment #37
mreda CreditAttribution: mreda commentedI guess that happens because
getPagerArgValue()
fails to retrieve date's granularity from the view. This patch worked for me.