Do not start with results in a SharePoint 2016 Search Webpart

 

I had a need to create a page with a search webpart on it, but I didn't want to show results as the default to begin with on the page. 

To accomplish this, in the search results query I changed this:

{searchboxquery} path:"https://sharepoint.contoso.com/Documents/*"

to this:

\\{searchboxquery?} path:"https://sharepoint.contoso.com/Documents/*" 

This makes it so that there are no default search results when the page is loaded, but it gives results when something is entered into the search box.

Taking it a step further, when the page is loaded, it gives an error that there are no search results. I wanted to remove that. So I did that by adding this CSS into a script editor webpart:

<style>

#NoResult{

display: none;

visibility: hidden;

}

</style>

Now, I only get results when something is entered into the search box, and no error message if there are no results.


Source: https://sharepoint.stackexchange.com/questions/187573/avoid-default-results-in-search-result-web-part

Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment

0 comments:

Post a Comment