I’m trying to create an Answers Experience that allows a user to filter through all results that are initially loaded on a vertical page. If I set the displayAllResults: true, this will happen when the a user interacts with the filters but I can’t get it to initialize to “DisplayAllResults” on page load.
Here’s what I want the user to see as soon as the answers experience loads:
and here’s what it currently looks like:
Hi Paige,
displayAllResults
only controls the no results behavior. To accomplish what you’re looking for (displaying results on an empty vertical search), you’ll want to take two steps:
1. Set up your Search Bar component to allow empty search.
On verticals, we will automatically show all results if a user conducts an empty search. By adding "allowEmptySearch": true
, we allow this behavior. You’ll find this in the componentSettings
object in your pages’s config.json file.
"SearchBar": {
"placeholderText": "Search for Stories", // The placeholder text in the answers search bar
"allowEmptySearch": true
},
2. Set a default initial search to that empty search.
Now that we’re allowing an empty search, we can set that as the default when someone lands on the page. You can find this within pageSettings
in the search
object.
"pageSettings": {
"search": {
"verticalKey": "faqs", // The vertical key from your search configuration
"defaultInitialSearch": "" // Enter a default search term
}
},
Let me know if this helps!
Best,
Amani
1 Like
I actually don’t have the Search Bar on this experience. (I just want the filters) Would you recommend showing the search bar and hiding it with CSS to mimic this behavior?
Yep I would move forward with that approach! That said, our best practice is to keep the search bar to allow users to easily navigate & find the results they’re looking for.
That worked for me. Thank you
@afarooque just a quick followup question to this, does it count as a search each time those default results displays are loaded (for things like Analytics, scoping, etc.)?
Yes, this does count towards analytics as a search.