Display Template Series
- Brief Introduction into Display Templates
- Content Search WebPart and Display Templates
- Display Templates and the ManagedPropertyMapping Custom Element
- Debugging Display Templates.
In SharePoint 2013, for search result Web Part you have the ability to customise your search results. Yes in 2010 you could customise the content query Web Part and search results, but you had to use XSLT to do this. Something I never got round to learning.
Site Settings > Master Page Gallery > Display Templates
The Search folder is where the files relevant for the Search Results Web Part are kept. The Content Web Parts folder is where the files relevant for the Content Search Web part are kept. Now this is the gotcha that made me spend half my morning getting nowhere. If you only see just the .js files within any folder underneath Display Templates, it means you do not have the site collection feature “SharePoint server Publishing Infrastructure” activated. Once this feature is activated, you will see all HTML and corresponding .js files.
Create your own Display Template
I was going to write a step by step guide on how to create your own Display Template, but I believe a simple example by Erik Swenson is a good walkthrough video. http://erikswenson.blogspot.co.uk/2013/01/sharepoint-2013-display-templates.html All I can advise is;
- Only ever modify the .HTML files. When you upload the html file back into the Display Template folder it will automatically produce the .js file for you.