Skip to main content
Changed bullets to numbers.
Source Link
Michael West
  • 18.6k
  • 2
  • 42
  • 105

This is not something you can do ootb with the SearchResults component. I think you have a few options to achieve the functionality:

  1. Use the SearchResults component and add some custom JavaScript to your page that counts the results and hides the results and displays a text if needed - this places your logic in the browser and I'm not sure if it's that easy to get a good user experience this way (but I'm no js expert)
  2. Write a custom rule that checks the count and use that with personalization to show the desired component - this will work fine but in case of few results you will have done the query twice
  3. Write a custom Scriban extension to do your query and check the count (https://ggullentops.blogspot.com/2019/11/custom-sxa-scriban-extensions.html) Use that output to show a different component from within your Scriban template.
  4. Go fully custom.. write the query, check the output and display either a text or the results - you can use variants with your own components (https://ggullentops.blogspot.com/2017/03/variants-sxa-sitecore-rendering.html) and also make the component compatible with pagination (https://ggullentops.blogspot.com/2018/12/sxa-pagination-on-custom-component.html)

I think I would go for option 3 or 4...

This is not something you can do ootb with the SearchResults component. I think you have a few options to achieve the functionality:

I think I would go for option 3 or 4...

This is not something you can do ootb with the SearchResults component. I think you have a few options to achieve the functionality:

  1. Use the SearchResults component and add some custom JavaScript to your page that counts the results and hides the results and displays a text if needed - this places your logic in the browser and I'm not sure if it's that easy to get a good user experience this way (but I'm no js expert)
  2. Write a custom rule that checks the count and use that with personalization to show the desired component - this will work fine but in case of few results you will have done the query twice
  3. Write a custom Scriban extension to do your query and check the count (https://ggullentops.blogspot.com/2019/11/custom-sxa-scriban-extensions.html) Use that output to show a different component from within your Scriban template.
  4. Go fully custom.. write the query, check the output and display either a text or the results - you can use variants with your own components (https://ggullentops.blogspot.com/2017/03/variants-sxa-sitecore-rendering.html) and also make the component compatible with pagination (https://ggullentops.blogspot.com/2018/12/sxa-pagination-on-custom-component.html)

I think I would go for option 3 or 4...

Source Link
Gatogordo
  • 20.3k
  • 2
  • 39
  • 100

This is not something you can do ootb with the SearchResults component. I think you have a few options to achieve the functionality:

I think I would go for option 3 or 4...