- Issue created by @chrisolof
- πΊπΈUnited States chrisolof
Support added in the 3505618-support-facets-exposed-filters branch. Tested against a variety of facet filters with a variety of employed coders, single and multi-value selections. Seems to be working well at this point.
Pretty paths coder config is at the filter-level (it shows in the exposed filter options form). It is possible to combine pretty and regular query string facet filters (eg. "/view/category/foo-258?tag=33).
Filter order in the URL is currently just following the filter order already established in the view.
Still needs test coverage and likely some additional refinement - both hopefully coming in this week.
- πΊπΈUnited States chrisolof
Test coverage and small improvements added (some identified while adding the test coverage). This is now ready for review.
Attached is an immutable patch against 2.0.x representing the current state of the MR 20.
- πΊπΈUnited States chrisolof
In testing I found that the pretty path redirect response to the views exposed form submission was coming back with "no-cache" in the cache control header. Adding cacheability metadata to the pretty path redirect response seems to have solved the issue. This should improve performance on previously-requested facet filter combinations.
Attached is an immutable patch against 2.0.x representing the current state of MR 20.
- Status changed to Needs review
3 months ago 5:06pm 22 May 2025 - π¬π§United Kingdom c_archer Cumbria
Tried this path, but it does not appear to be working, do I need to do anything?
- πΊπΈUnited States mlncn Minneapolis, MN, USA
It works great!! Thank you chrisolof!
c_archer you need to do the configuration of Facet Pretty Paths on the View that has the facets, in the Filter criteria section, presented as (for an 'example' facet name) "Facet: Example (example)" β you need to press that name to configure
Pretty paths coder
, not the Settings link as we all would usually expect. - π¬π§United Kingdom effortDee
Just wondering when this will roll out?
- πΊπΈUnited States mlncn Minneapolis, MN, USA
Thought i should report π Remove last facet fails Active as related to hereβ TLDR i think the "prettiest" paths (no query string at all,
/view/category/foo-258
in the example above) seem a little incompatible with Facets via Better Exposed Filters or Views itself. - πΊπΈUnited States chrisolof
@mlncn It looks like BEF builds its links from the current path (eg.
/view/category/foo-258
), not the view's path (eg./view
), and thus includes any active pretty path parts in all of the URLs it generates - even links that are supposed to remove selected options.In other words it doesn't appear that BEF links (including the links widget) are fully-compatible with what we're doing here, yet. If BEF used the view's path (
/view
) as the starting point for its links, instead of the current path (/view/category/foo-258
), I believe its links would become fully compatible.You might consider proposing a patch to BEF that changes
Drupal\better_exposed_filters\Plugin\BetterExposedFiltersWidgetBase::getExposedFormActionUrl()
to pull the starting URL from$this->view->getUrl()
instead of the current request. In a quick test in my dev environment I just confirmed that little change in BEF does indeed resolve the BEF links widget issue you describe.I should also mention that moving to the checkboxes/radios BEF widget is another way to overcome the deselection issue, but that may not be right for your site.
- π©π°Denmark ressa Copenhagen
+1 for the MR, thanks @chrisolof! Your updated code works well with Facets 3 and Better Exposed Filters (BEF) using the "Exposed filter widget" set to "Checkboxes/Radio buttons".
I hope it can get committed before too long. Perhaps you could consider applying to become a co-maintainer, to help move this great improvement along?
- π§πͺBelgium StryKaizer Belgium
Great work,
However, in Facets 3, we are now avoiding to do custom, not facet-related, features anymore.
This is another example of something we should offload to a more global solution, which works for every views exposed filter (not only facets, and not only search-api-based views).That is why my preferred solution is fixing this in "Views Pretty Paths module" (similar to how we also moved the functionality from "Facets summary" to "Views Exposed Filters Summary", which benefits everyone).
I understand that "Views Pretty Paths module" does not (yet) support the coders plugin system. We should probably contribute that part too in that module.
But for people who need this functionality now: feel free to use the patch above.
The "facets summary" module will probably not change much anymore, as we are focusing on global solutions. So the patch should be working for a long time without too much re-rolls ;-) - π©π°Denmark ressa Copenhagen
Thanks for clarifying the situation and plan @strykaizer, and that we can probably safely use the MR here for the time being.
Just out of curiosity, will Facets Pretty Paths eventually be totally replaced by Views Pretty Paths β ? Perhaps a short "Future plans" section with a sentence or two from your comment could be added on the project page? Should this issue be set to "Postponed"? (I added a short update in the Issue Summary).
It sounds great that you may take a look at getting this feature in "Views Pretty Paths" module soon, and I (and probably the rest of the users here) will be ready to test an MR when it's ready. Have a great day!
- π§πͺBelgium StryKaizer Belgium
Facets pretty paths will stay available for users using Facets 3 with Facet entities (Facets as a block), and Facets 2 users.
However, the recommended way in Facets 3 is now to use "Facets Exposed Filters".
People using "Facets Exposed Filters" will not need this module anymore in the future.I updated the project summary to clarify. Thx!
- π©π°Denmark ressa Copenhagen
Beautiful, thanks @strykaizer!
The description on the project page is an invaluable resource, both for finding the correct and best solution in the first place, assess its features and limitations, and review future plans, and with your addition, all bases are covered.
I am using the new Facets 3 methods for my latest project, and it works really well. Managing all filters via a single block is a big improvement, and being able create filters directly in the View (and not on their own page) is another improvement. So making the Facets ecosystem modules more globally reusable, turns out to be a correct strategic decision. So thanks for your great efforts with Search API and Facets in Drupal, I very much appreciate it.