1
Display Error: The display template had an error. You can correct it by fixing the template or by changing the display template used in either the Web Part properties or Result Types.


Template '~sitecollection/_catalogs/masterpage/Display Templates/Search/Control_SearchResults.js' not found or has syntax errors. (LoadTemplate: )

I am getting this error when searching from a different machine. It works fine when I search within the server. The .js file is not missing and I don't think there are syntax errors in them as I haven't touched their contents.

Similar questions had solutions like adding the site to the trusted sites list which didn't work for me.

Any help will be very much appreciated.

6
  • Make sure the file is actually published, so that there is a major version for users to find that do not have edit permissions on it Commented Dec 15, 2014 at 11:06
  • Yes, the file is published. I've also compared its configuration with my other machine which is not having the issue and they are the same.
    – Nathan
    Commented Dec 15, 2014 at 11:11
  • use an admin account, does it still do the same? also is both JS files to compare the same or different?
    – Ali Jafer
    Commented Dec 15, 2014 at 11:48
  • Same thing happens with an admin account. The .js files are the same; they're default SharePoint Search templates.
    – Nathan
    Commented Dec 15, 2014 at 12:48
  • Is there an error in the Browser Dev tools? Commented Jan 7, 2015 at 10:48

6 Answers 6

1

You must publish not only the display template file but also any refinement items that you may be using on the search page.

Go through everything in the SharePoint Design Manager: Edit Display Templates page and make sure that the Approval Status is "Approved" for everything on the page in question.

You get there by going to Site Settings -> Site Collection Administration -> Go to top level site settings.

From Top Level site: Site Collection Admin -> Search Result Types.

There is a link within the first sentence at the top of the page for crafting a display template in HTML. Click on the display template link to get to the approval page.

0

On SharePoint 2013 Management Shell as Administrator run the following command:

Enable-SPFeature SearchWebParts -url central_admin_url

This resolved the above issue in my environment. Make sure the URL is the administration URL (E.g. : http://sp-server:11186 ), not the intranet/default site URL.

1
  • Not sure why it is down vote. I think your solution is best among all.
    – Mark L
    Commented Apr 29, 2016 at 3:50
0

Had the same issue in o365 and had to go to this specific page and publish a major version on the html display templates:

{YourSharePointSite}/_layouts/15/DesignDisplayTemplates.aspx

0

FOR SOME WEIRD REASON I FIXED MINE BY DOING IISRESET enter image description here

-1

Open other Site Collection using SharePoint Designer and go to top path and copy the Control_SearchResults.js to same path at your Site Collection that has the problem.

3
  • 1
    I'm not sure I understand what you mean. Could you extend the explanation, please?
    – Benny Skogberg
    Commented Jun 29, 2015 at 8:35
  • 1
    If i am not wrong, M.Ashkboos meant you need to copy "Control_SearchResults.js" from any site collection (if available) where its working properly, to you site collection where you are getting error. (In a way resetting Control_SearchResults.js to its default state)
    – 404
    Commented Jun 29, 2015 at 8:45
  • YES,I mean that
    – M.Ashkboos
    Commented Jun 29, 2015 at 10:58
-1

None of the above worked for me. What worked was granting full control access to the template's .js and .html files to all my users.

1
  • Full control to all users? That is a huge security risk and certainly not needed Commented Oct 24, 2016 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.