Hi Josef and all maintainers of Pretty Paths!

Case
I try to use both Global Filter and facets to filter views.
When Global filter has value and Pretty Paths is on clicking on any Facet views shows empty results.
And at the same time it works fine without Pretty Paths when Facet API Pretty Paths is disabled.
So it works when urls are not aliased and look like this: site.com/search?f[0]=field_city%3A7001

I tried to disable in Global filter setting to transmit values through HTTP GET and enabling Pretty Paths. It didn't help.

Questions:

  1. May you suggest how to fix it?
  2. May you explain why it can happen?

Facet API Pretty Paths Settings
screen

Global Filter Settings
Global filter is set to use HTTP POST to transmit values.
Global filter block widget is select dropdown (taxonomy term views).
Optimize is not used in global filter settings.

Global Filter 7.x-1.11
Facet API Pretty Paths 7.x-1.0
Search Facets 7.x-1.6
Search API 7.x-1.6

Thank you for your time and energy to make drupal better!

Mike

CommentFileSizeAuthor
#2 1n1.png7.72 KBJarviss
#2 1n2.png91.66 KBJarviss
#2 1n3.png37.22 KBJarviss
scr1.png35.02 KBJarviss
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jarviss’s picture

Issue summary: View changes

wrong screen file

dasjo’s picture

Title: Compatibility with Facet API Pretty Paths on Search API views » Compatibility with Global filter on Search API views
Category: bug » support

hi,

i'm changing the issue title, hope this is more accurate as its about compatibility with https://drupal.org/project/global_filter

i haven't used this module but if it uses HTTP POST for setting filter values this might reset the pretty path.

Jarviss’s picture

FileSize
37.22 KB
91.66 KB
7.72 KB

Hello Josef!

I checked your idea about POST.

I tried to change widget from Select Dropdown to list of links
as Select widget can use HTTP POST by default
1
2

and made settings for this module to use HTTP GET.
So The link now looks like /src/category/cinema-tickets-5?view_city=4

2

But still it doesn't filter views you can check it on demo!

Jarviss’s picture

Josef Views Global filter works as Contextual filter Argument to Views (you may look at Argument Settings in views),
it uses Session to store its values and Session cache module.

dasjo’s picture

to narrow down the problem, have you tried if everything works for you without the global filter?

Jarviss’s picture

Yes Josef Pretty Paths work fine with Facet Api and views is filtered. And also Global Filter works fine without Pretty Paths on!
So when both Global filter is managed to filter views and Pretty Paths is on Views return empty results.

RdeBoer’s picture

Title: Compatibility with contextual filter defaults on Search API Views » Compatibility with contextual filter deafaults on Search API Views

So, I did some research into this...

The problem has little to do with Views Global Filter.
It is because Facets Pretty Paths is unable to honour CONTEXTUAL FILTER DEFAULTS. Instead Facets Pretty Paths obliterates any contextual DEFAULT arguments that may be present in the URL.
If Facets Pretty Paths can be made to accept contextual filter defaults, then this also solves the issue with Views Global Filter, because Views Global Filters ARE contextual default filters.

Steps to reproduce.
You may uninstall Views Global Filter, as it has nothing to do with the issue.
Create in the search View (let's say at path /src) a contextual filter for Taxonomy Term field_city and provide a Fixed default value of, say, 2 (e.g. London).

Without Facets Pretty Path, the URL: /src?f[0]=field_category:5 WORKS (taxonomy term will be used as the 2 is the default contextual argument set up in the View)
With Pretty Path URL switched on: /src/category/Cinema Tickets-5 DOES NOT WORK: the word 'category' will be interpreted by the View as the first contextual argument, i.e as the value to be used for field_city, to contextually filter on. 'category' is of course not a valid taxonomy term id for field_city.

To try and get around this I introduced Global:Null filter and "Indexed Node: Category" as contextual filters preceding the field_city contextual filter, so as to cover the 3 elements of the URL path generated by Facets Pretty Paths. But this doesn't seem to work on Facets Pretty Path URLs like /src/category/Cinema Tickets-5 except for the URLs /src/category, /src/category/all or /src/category/all/term_id (the taxonomy term field_city is the final contextual argument, defaulting to 2).

To solve this the Views contextual filter for "Indexed Node: Category" needs to be made to understand the "Cinema Tickets: 5" format.
I guess this is best implemented in one of the Search API or Facet API (sub)modules.

dasjo’s picture

Title: Compatibility with Global filter on Search API views » Compatibility with contextual filter defaults on Search API Views

thanks for looking into this rik!

so this boils down to the fact that pretty path aren't compatible with views contextual filters as both are passed as arguments right?

obviously this causes conflicts between the path logics of views contextual filters + facet api pretty paths. you still can use any GET paramenter based filters. (this might be a good candidate for an FAQ :) )

i think we might even want to remove "defaults" and "search api views" from the issue title, as this should be valid for any contextual filter being used with views.

RdeBoer’s picture

Title: Compatibility with contextual filter deafaults on Search API Views » Compatibility with contextual filter defaults on Search API Views

@dasjo, #7

Yes, Josef, your summary of the issue is correct except for the the bit "this should be the case for any contextual filter being used with Views".

If I remember correctly, it handles contextual filters that are present in the URL correctly: it appends the contextual filter to the URL first and then appends the "/category/Cinema Tickets-5 bit after that -- so that's fine.
It's just where the contextual filter is omitted (defaulted), the Pretty Path takes its place and thus destroys the contextual filter default. That's why I tried the approach in #6, introducing a "dummy" contextual filter to skip the /category part and then have the original contextual filter default applied as the last (third) in the list. But unfortunately the second contextual filter /Cinema Tickets-5 is not understood in that case.

Rik

dasjo’s picture

ok thanks. i'd like to provide some more background info for anybody interested in fixing this problem:

pretty paths tries to remove any path segment that can be detected and then leaved the remainder to views as its base path.
we have had quite some attempts to get this right, see #1861786: Fix base path issues

also see the logic for path processing in pretty paths

dasjo’s picture

Status: Active » Closed (won't fix)

I just re-read the comment from #10

It's just where the contextual filter is omitted (defaulted), the Pretty Path takes its place and thus destroys the contextual filter default. That's why I tried the approach in #6, introducing a "dummy" contextual filter to skip the /category part and then have the original contextual filter default applied as the last (third) in the list. But unfortunately the second contextual filter /Cinema Tickets-5 is not understood in that case.

This interference can't really be avoided within the module, so updating the status.

Feel free to report if you have further ideas.

dasjo’s picture

Issue summary: View changes

etc