Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
} 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