Yesterday we had the first Biwug Quiz. One of the questions was the following:
Display Templates require one of the following options:
- HTML
- JavaScript
- JavaScript & HTML
- XSL
Everyone has answered that you need the JavaScript and HTML file, but this isn’t correct. The correct one was number two JavaScript. To clarify the answer I will show you why you don’t need the HTML file.
The HTML file only makes the creation process of display template easier.
If you create a new site collection from the team site definition, you will only have the JavaScript files available in the master page gallery.
The HTML versions become available once you have activated the SharePoint Server Publishing Infrastructure feature.
If you aren’t working with the HTML file (what I don’t recommend) you will have to do some manual actions.
First of all, start by making a copy of one of the existing display templates. I choose to create a copy of the Item_TwoLines.js file.
The next step is to modify the properties for that file like this:
Once you have modified these properties, it is time to change the template a bit.
To start you will need to update your template URLs in the display template because the reference will be set to the old file.
|
|
Then it is up to you what you want to modify in the template, I added a text element that shows “My file extension is: FileExtension”.
This is the end result: