Saturday, July 6, 2013

SharePoint 2013 Search WebParts and Display Template

SharePoint 2013 Search Webparts, are configured with Display Templates unlike previous versions of SharePoint . This  is quite useful as Search customization become easy with editing just snippet of htmls and JS  rather than complex XSLT transformations.Take a look at Display Templates  reference
 and this one to know about how Display Template are structured

To know about how each Display Template  associated with  each Search Webpart,
In Site Settings Menu --> Select Design Manager-->Edit Display Template and Filter by  search Webpart as shown in following image.
and then filter with  Filter Content Type,Here you can decide ,how to customize different search webpart associated with different Display Template

Now if you want to upload Customized Display Template, Upload it in Master Page gallery-->Display Template-->Search

Lets  take an example of Refiner WebPart. If you edit this WebPart in Search Page ,you will  find every managed property( of type string/Int/Date/Bool is associated with Display Template.
If Managed Property is of Type Int or DateTime, you can customize Refiner Webpart to refine it by Slider Template with Bar Graph. (but Note, unless managed property has values  , nothing will be shown up)

Once you save changes, awesome  slider refiner will appear in Refiner WebPart
For  Custom managed properties take a look at this awesome post