Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Followup for #2974512-9: Facets range widget directly alters the url.
+++ b/modules/facets_range_widget/src/Plugin/facets/processor/RangeSliderProcessor.php @@ -46,25 +46,15 @@ class RangeSliderProcessor extends SliderProcessor implements PreQueryProcessorI + $new_active_filters[$facet->getUrlAlias()][] = '(min:__range_slider_min__,max:__range_slider_max__)'; + $url = \Drupal::service('facets.utility.url_generator')->getUrl($new_active_filters, FALSE);
getUrl use keys to determine facet id's, not aliases
It should be:
$new_active_filters[$facet->id()][] = '(min:__range_slider_min__,max:__range_slider_max__)';
Comment | File | Size | Author |
---|---|---|---|
#4 | 2994859-3-facets_fix_range_processor-tests.patch | 1.77 KB | 5n00py |
#2 | 2994859-facets_fix_range_processor.patch | 1003 bytes | 5n00py |
Comments
Comment #2
5n00py CreditAttribution: 5n00py as a volunteer commentedComment #4
5n00py CreditAttribution: 5n00py as a volunteer commentedUpdate tests.
Comment #5
michaellenahan CreditAttribution: michaellenahan at Hubert Burda Media commentedThanks. I was hitting this error in facets/src/Utility/FacetsUrlGenerator.php
After applying this patch, the correct $facet_id was passed to the facetStorage->load() function.
Marking as RTBC.
Comment #7
borisson_Thanks!
Comment #9
matuspo CreditAttribution: matuspo commentedHi everybody,
I came here as I got a problem with URL query params generation, when using range slider. The problem is, that anytime I change the slider values, it appends new query param instead of changing current one.
Example:
f[0]=variations_product_variation_cena_cislo%3A(min%3A3205%2Cmax%3A13705)&f[1]=variations_product_variation_cena_cislo%3A(min%3A3205%2Cmax%3A17305)&f[2]=variations_product_variation_cena_cislo%3A(min%3A405%2Cmax%3A17305)
As you can see it's same facet with different values.
I found that the patched line should be like this:
I tested it and now there is just one query parameter for specific facet.
Comment #10
jonas139 CreditAttribution: jonas139 at iO commentedHey Matuspo,
I was having the same problem but there's another active issue that maybe can help.
https://www.drupal.org/project/facets/issues/3055897