Friday, January 2, 2015

How to Add Totals to Search Refiners in SharePoint 2013

So for every Search project I work on this requirement always surfaces, which is why I am confused to why Microsoft did not default the refiners to include the totals.  Including totals in your refiners is actually very easy and only requires a small modification to your Search Filter refiner.  Depending on whether you are utilizing a single option refiner or the multi value refiner will determine which filter refiner you will need to update.


Single Selection
              Filter_Default
Multiple Selections
             
Filter_MultiValue
The first step to modifying the refiner(s) is to locate them

How to Locate Your Filter Files:
(Note: We do not want to modify the JS Files, any updates we make to the HTML files will propagate to the linked JS files.)

  1.   Site Settings
  2.  Master pages and page layouts
  3.  Display Templates
  4.   Filters
  5. Save a copy of either the Filter_Default.html and/or Filter_MultiValue.html files to your desktop
How to Modify Your Filter Display Templates
Now that we have saved copies of the filter display templates, it is time to edit them in order to display totals.

  1. Open the files in a text editor i.e. Notepad++, Notepad, SharePoint Designer, Visual Studio, etc 
  2. Modify ShowCounts: to equal true
Original

<!--#_
 
    this.Options = {
        ShowClientPeoplePicker: false,
        ShowCounts: false
    };
Updated
<!--#_
 
    this.Options = {
        ShowClientPeoplePicker: false,
        ShowCounts: true
    };

After making the update from false to true you will need to upload the new file and publish the changes.  By using the exact same file name your changes should be saved as a new version to the file, if you were not modifying it directly.

Best Of Luck!
Dan

No comments:

Post a Comment