-2

I have a list view whose path is /search-by-color with better exposed filters being enabled. This view manages the nodes of type "Car" and has an exposed filter called "CarColor" and it is displayed as a select list with a checkbox next to each option. On the details page of a node of type Car, I have a link "Click here to view all cars of the same color" that points to the list view page with query parameters in the url as follows: Preprocessing :

$variables['sameColorPath'] .= "?field_car_color_target_id%5B" . $currentnode_color_id . "%5D=" . $currentnode_color_id;

Template: <a href="{{ path('view.page_liste.colorsearch') ~ sameColorPath}}">Click here to view all cars of the same color</a>

When I click on the link, I am redirected to the url www.example.com/search-by-color?field_car_color_target_id%5B8%5D=8 where 8 is the $currentnode_color_id referring to red. and the exposed filter CarColor is correctly set to Red. However, the problem is, when I deselect the Red checkbox from the list of CarColor options, such that no color is selected, I still get the results as if the Red is selected . Is this due to the url that remains in this format www.example.com/search-by-color?field_car_color_target_id%5B8%5D=8 ? If yes, how can solve this issue?

Note that I deselect the Red checkbox from the list of CarColor options, and select another color ,say Green, the view displays the right results (list of green cars) even though the url remains the same www.example.com/search-by-color?field_car_color_target_id%5B8%5D=8 .

One last thing that I noticed is that the problem described does not exist when I visit www.example.com/search-by-color directly, without clicking on the link "Click here to view all cars of the same color". In this case too, the filter works perfectly, when I choose an option, it displays the right content however it doesn't show up in the url as a query parameter so the url remains /search-by-color. This is not an issue but I was wondering why the url was not affected.

2
  • Your description isn't very clear and I don't even know what your question is, but overall this sounds like a caching issue.
    – Hudri
    Oct 6 at 10:44
  • @Hudri when no option in the filter is selected, I want all the results to be displayed. currently, when I manually deselect the red, I still only have the red cars displayed, I want all the cars to be displayed if no filter is selected
    – user105449
    Oct 6 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.