SharePoint 2013 Remove ‘Nothing here matches your search’ from search results web part
To change this...
Search Results web part of SP 2013 uses ‘Control_SearchResults.html’ display template which is available under Master Page Library –> Display Templates –> Search.
Solution:
Rename the ‘Control_SearchResults.html’ file to some other name e.g. ‘Control_Test_SearchResults.html’
Open this file in any text editor like notepad.
Change the Title in this HTML file, this title will be available for selection in web part properties.
Now we want to get the search text entered in to search box web part, for that we will use ctx object as following ctx.DataProvider.get_currentQueryState().k
Search for
if(ctx.ClientControl.get_shouldShowNoResultMessage()){ line in HTML file
Replace above line with
var currentQueryTerm = ctx.DataProvider.get_currentQueryState().k; if(ctx.ClientControl.get_shouldShowNoResultMessage() && currentQueryTerm!=””){
Save the modified HTML file.
Go to Master Page Library –> Display Templates –> Search and upload new control template.
You will see that respective ‘Control_Test_SearchResults.js’ will be created by SharePoint.
Now go to your page where Search Result web part is added, edit Search results web part. Under Display Templates section select newly uploaded display template.
Save the changes and that’s it, you will see the expected result.
To change this...
Search Results web part of SP 2013 uses ‘Control_SearchResults.html’ display template which is available under Master Page Library –> Display Templates –> Search.
Solution:
Rename the ‘Control_SearchResults.html’ file to some other name e.g. ‘Control_Test_SearchResults.html’
Open this file in any text editor like notepad.
Change the Title in this HTML file, this title will be available for selection in web part properties.
Now we want to get the search text entered in to search box web part, for that we will use ctx object as following ctx.DataProvider.get_currentQueryState().k
Search for
if(ctx.ClientControl.get_shouldShowNoResultMessage()){ line in HTML file
Replace above line with
var currentQueryTerm = ctx.DataProvider.get_currentQueryState().k; if(ctx.ClientControl.get_shouldShowNoResultMessage() && currentQueryTerm!=””){
Save the modified HTML file.
Go to Master Page Library –> Display Templates –> Search and upload new control template.
You will see that respective ‘Control_Test_SearchResults.js’ will be created by SharePoint.
Now go to your page where Search Result web part is added, edit Search results web part. Under Display Templates section select newly uploaded display template.
Save the changes and that’s it, you will see the expected result.