2

I'm using the Search Plus plugin with Craft, it's been a great help! I have 2 questions I need help with, as the Search Plus docs are not too clear so far:

  1. I have a search page with filters (facets) in place, however these facets are arranged according to search count by default. I want to sort them by alphabetical order instead, and I've seen that it is possible with Algolia, but I need help to do that with Search Plus.
  2. Upon clicking on a filter checkbox, the other filters disappear. How do I trigger them to still appear but with a different CSS class applied?
1

I ran into the same problems as you and I believe I've solved it, but it may be different for your specific use case.

  1. There may be a way to control this with the init options but I wasn't able to find a way to do it, so I just edited the searchplus.js code directly in the searchplus folder. Look for something like e.getFacetValues(i,{sortBy:["isRefined:desc","count:desc"]}) and change it to e.getFacetValues(i,{sortBy:["name:asc"]}) instead (you can leave the isRefined:desc part at the front as well if you would like the filtered options to automatically populate to the top of the list). Keep in mind that changing the js file is a global change which would affect other faceted forms if you have more than one on your site.

  2. When you define the facets in your init code: $(this).searchplus({facets: ['facet1', 'facet2'],});, replace facets with disjunctiveFacets and you should stop seeing filters disappear from the facet you're selecting (see faceting options on the Search Plus docs. The other facet's filters will disappear though depending on if there are valid matches or not, but it will at least prevent the other filters from your selected facet from disappearing immediately.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.