Currently Drupal make ajax request via post method so checking q query parameter not working.
So that requires additional check on PrettyPathsActiveFilters.

Comments

voleger created an issue. See original summary.

voleger’s picture

Assigned: voleger » Unassigned
Status: Active » Needs review
StatusFileSize
new668 bytes

Here the patch.

alex_optim’s picture

Work for me.

kachinsky’s picture

#2 didn’t work for me.
In my ajax view after applying the filter, if I click on the next page, instead of the next filtered page, I see the view without filtering.
I've debugged it a little and found out that q is NULL for url like "?q=/en/products/category/buckets-802&sort_by=created&page=1", from request object I can only get page and sort_by parameters.

colorfield’s picture

StatusFileSize
new752 bytes
new627 bytes

I can reproduce #4, it seems that $_REQUEST['view_path'] applies to the originally accessed url.
So if /my-view or /my-view/filter-1 is accessed, it will set this path even after a facet change (e.g. /my-view/filter-2).
If we follow the same principle, we could workaround this by making use of the referer, not sure if this is valid approach though.
I've tested with other query string parameters like full text search or pagination it seems to be fine.

kachinsky’s picture

I tried patch #5 and I can confirm that it solves the problem.
Thanks @colorfield

spuky’s picture

Patch #5 is also working for me... Thanks

rgeerolf’s picture

Patch #5 is also working for me.

DonAtt’s picture

#5 works for me together with the Facets 2.0.x AJAX fix: https://www.drupal.org/project/facets/issues/3052574#comment-15050142

DonAtt’s picture

joseph.olstad’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

szeidler’s picture

With Drupal 10.1 views is using GET AJAX requests by default, when AJAX is enabled.

In my case we're using views_infinite_scroll and the path context is lost, because of the POST limitation in this commit. I think we would need to make it work with GET requests as well now.

joseph.olstad’s picture

@szeider, if you could kindly share a solution to this, I'll review it.

joseph.olstad’s picture

Status: Closed (fixed) » Active

D10.1-only issue?

szeidler’s picture

Yes, the problem is tied to Drupal 10.1 where the support for AJAX GET requests has been introduced and made the default for example pagination.

It's essentially about this line.

if ($q === NULL && $this->request->isMethod('POST') && !empty($_REQUEST['view_path'])) {

I don't know why the limitation to the method was made, but in my test case changing it to the following resolved the issue

if ($q === NULL && !empty($_REQUEST['view_path'])) {
colorfield’s picture

StatusFileSize
new678 bytes

Thanks @szeidler for mentioning the core changelog and the fix, works for me too. I don't think that removing POST limitation would cause any issue. Here is a patch, it should also apply to 2.0.x branch https://git.drupalcode.org/project/facets_pretty_paths/-/blob/2.0.x/src/...

colorfield’s picture

Status: Active » Needs review
dan2k3k4’s picture

Status: Needs review » Reviewed & tested by the community

Removing the `$this->request->isMethod('POST')` check seems like the best approach. We could have checked if `POST or GET request` but I don't see any reason for such limitation.

Tested on one client project and working as expected.

joseph.olstad’s picture

This seems like an important fix.

Would someone be willing to wrap this new condition in a version check?

if (version_compare(\Drupal::VERSION, '10.1', '>=')) {
  // Run the Drupal 10.1+ logic
}
else {
  // Run the original logic.
}
rossb89’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new916 bytes

Re done the patch with the additional logic check requested above :)

  • joseph.olstad committed 067c6369 on 8.x-1.x authored by voleger
    Issue #3129632 by colorfield, voleger, rossb89, joseph.olstad: FPP lost...
joseph.olstad’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.