Recent searches
No recent searches
Search Results - select Article type by default
Answered
Posted May 10, 2023
Hi all,
Is it possible to select by default the Articles type on the search results page (instead of All types)?
We're finding in our help center that most users don't even know to select the Articles type to show the By category subfilter. We didn't even realize that function ourselves when we were building the help center. It's just not intuitive.
If Articles is selected by default, users will always see the categories.
Thanks
1
13
13 comments
Ifra Saqlain
Hi :)
@Rob R
I worked on your query and I found this:
Add it to document_head.hbs file.
Replace this URL with yours:
https://support.zendesk.com/hc/en-us/community/posts/5683688413338-Search-Results-select-Article-type-by-default
0
rob.roberts
Thanks for the quick reply, Ifra!
The only thing is that the page still loads to the standard results view, then one second later it refreshes to the redirect URL. I thought the '0' in the code is supposed to make it immediate?
Side note: I needed to change /search to search?utf8, since both the original results URL and the redirect both contain /search (and resulted in a page refresh loop).
0
Ifra Saqlain
O o! I only tested for external URL instead of search results.
I'll fix it and provide new solutoin.
0
rob.roberts
OK, thanks!
0
Kel S.
Hi, just asking politely for some help on this as I can't get the code to work (it goes in the loop as mentioned by Rob).
Is the URL that's meant to be replaced (https://support.zendesk.com/hc/en-us/community/posts/5683688413338-Search-Results-select-Article-type-by-default) supposed to be the just the domain? The link to the search page?
And with the replacement of the search?utf8, does that mean the code is this?
0
Ifra Saqlain
Hi Kel S., actually when you add external URL in the code it won't be stuck in a loop but I'm checking the search page in the condition so the page is same on every reload that's why code executes again and again.
I tried to solve it from my side but my bad :(
0
David Monteiro
Hi Ifra Saqlain,
I had the same issue in the sense that I wanted the user to able to clearly understand where their search was applied - and we don't have a community yet.
I'm using the following script based on yours :)
But would there be a more elegant way to do it? Especially that doesn't involve a refresh of the page?
0
Ifra Saqlain
Hi David Monteiro, I tried it to get it done but that same bug occurs, infinite page refresh loop...
The code is working for external URL but when I try for search page I stuck in same issue :)
0
Fernando
Ifra Saqlain, after a lot of tinkering I was able to add the script tag below at the bottom of the search_results.hbs with the following results:
2
Ifra Saqlain
Mr. Fernando, it's really nice trick and it will help to other members. Thank you so much that you shared it here and I learned it too :)
0
Rasmus Hedback
Another approach would be to let the form build the correct query string when submitting it, simply add a hidden input by adding this to script.js
1
Ifra Saqlain
Hi Mr. Rasmus Hedback :),
Thank you for the nice tip.
0
Elena Ara
Thank you Fernando !
This was exactly what I was looking for! Kudos to you ^_^
0