Skip to content

Instantly share code, notes, and snippets.

@beckettkev
Created December 17, 2015 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beckettkev/473e74a5b9fab5b406ce to your computer and use it in GitHub Desktop.
Save beckettkev/473e74a5b9fab5b406ce to your computer and use it in GitHub Desktop.
} else if (hasControl && !$isNull(listData)) {
//set a boolean variable to tell us if the current refiner being processed by the display template is our custom one
var isWorkspaceRefiner = ctx.RefinementControl.overrideDisplayName === "Workspace" && ctx.RefinementControl.propertyName === "SPSiteURL";
for (var i in listData) {
...
if (ctx.RefinementControl.propertyName == "MediaDuration") {
Srch.U.modifyMediaDurationRefinementName(listData[i]);
}
//this is the place in the display template where we will call our custom logic (if it is our refiner)
...
if (isWorkspaceRefiner) {
if (typeof listData[i].RefinementName !== 'undefined') {
//invoke our custom refiner logic
listData = MyCompany.MyProject.Search.Workspace.SetWorkspaceRefinementItem(listData,
{
Id: i,
Property: 'Path',
Type: 'contains'
}
);
}
}
...
//the end of the for loop
}
if (isWorkspaceRefiner) {
//lets show ten items, if available by default in our custom refiner (otpional)
shortListSize = 10;
//Remove unnecessary refinements from the Workspace Refiner (in reverse order to preserve the indecises of the array)
listData = MyCompany.MyProject.Search.Workspace.RemoveDeadRefinerItems( listData );
//Sort by refinement count (optional)...
listData = MyCompany.MyProject.Search.Workspace.SortByRefinementCount(listData);
//House keeping and we are done...
MyCompany.MyProject.Search.Workspace.ClearExistingMatches();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment