Friday, 19 September 2014

SharePoint Display Templates

Display Templates:
Display Templates are used with CSWP to format/style search result generated by CSWP search query. Display Templates control which managed property is shown in the
search results and how they appear in the Web Part. Each Display Template has two files: an HTML version of the Display Template that you can edit in your HTML editor,
and a .js file that is for SharePoint use and should never be modified. CSWP uses combination of two Display Templates, Control Templates and Item Templates to render
results.
Control Template provides HTML to structure the overall layout for how you want to present the search results. For example, the Control Template might provide the HTML
for a heading, beginning and end of a list. The Control Template is rendered only once in the Web Part.
Item Template provides HTML that determines how each item in the result set is displayed. For example, the Item Display Template might provide the HTML for a list item
that contains a picture, three lines of text that are mapped to different managed properties associated with the item. The Item Display Template is rendered one time
for each item in the result set. So, if the result set contains ten items, the Item Display Template creates its section of HTML ten times.
Display Templates Location in Server:
Open SPO–>Settings–>Site Settings–>Design Manager –>Edit Display Templates
or
Open SPO–>Settings–>Site Settings–>Master pages and page layouts
Click on libraray
Open with explorer. Or Click on Display Template folder–>Content web parts
Check and html–>Download
Change this file and upload with new name. Js will create automatically.
Or
Open SPD:Open SPO–>Master Pages–>Display Templates
==>Content Web Parts
Here you can see files start with “Control_” and “Item_”.
Files starting with Control are Control Templates and files starting with Item are Item templates.
Also there are two file extensions for each file type .html and .js.
.js is strictly for SharePoint internal use and not to be changed by users.