1

I have a site with a few channels each with a lot of entries. When retrieving the results from a site search, I’d like to show a paginated list of entries from all sections by default, but then have filters in a sidebar which retrieve only entries from a certain channel, again in a paginated list.

How can I initially show the total number of entries in each channel for a particular search term, without having to actually construct a query for each channel individually which would be really slow?

The behaviour would be identical to the following example where it lists the number of entries for each ‘Material type’ http://explore.bl.uk/primo_library/libweb/action/search.do?dscnt=1&tab=website_tab&dstmp=1461161587439&vl(freeText0)=family&fn=search&vid=BLVU1&mode=Basic&fromLogin=true

1
  • Even easily being able to identify which channels have at least one entry so the filter list only contains relevant channels would be good.
    – Alex H
    Apr 21, 2016 at 9:44

1 Answer 1

1

I would try one of the following solutions:

  1. Using Ajax to display the search results and the filter

    Use ajax to display your search results. After loading the search results, you'r using a second Ajax call to get the categories filter. With this solution the visitor see the results quickly and get the filter after. You could try to including caching of the filter to speed up the page. Downside: Depending on requests and amount of content, it needs still a lot of server power.

  2. Writing your own Plugin

    Write your own search filter plugin with your logic and optimized SQL to get the filter faster. This solution can be combined with the first one.

  3. Using a external Search Engine

    A other solution could be to use a external search engine service like Google Custom Search. Some of them offers filters/logic like you need. Craft CMS Example: On https://straightupcraft.com/craft-plugins/ the search is provided by Algolia (https://www.algolia.com/). On the right side is a simple developer filter, including number of entries. Take also a look at the Algolia Plugin to easy integrate Algolia in Craft CMS -> https://straightupcraft.com/craft-plugins/search-plus-1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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