Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
[IMPROVEMENT] Enforcing a suggestion limit when hundreds may exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Glasl committed Feb 28, 2018
1 parent 9e499a5 commit 04766a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [extensible search](https://packagist.org/packages/nglasl/silverstripe-extensible-search)

_The current release is **4.0.1**_
_The current release is **4.1.0**_

> This module allows user customisation and developer extension of a search page instance, including analytics and suggestions.
Expand Down
8 changes: 7 additions & 1 deletion client/javascript/extensible-search-suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
'label': term + '<strong>' + this.substr(term.length) + '</strong>',
'value': this
});

// Enforce a limit.

if(options.length === 5) {
return false;
}
}
});
response(options);
Expand All @@ -55,7 +61,7 @@
.data('ui-autocomplete')._renderItem = function(ul, item) {

return $('<li>').append($('<div>').html(item.label)).appendTo(ul);
}
};
}

});
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
"dev-master": "4.1.x-dev"
},
"expose": [
"client"
Expand Down
4 changes: 2 additions & 2 deletions src/services/ExtensibleSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getPageSuggestions($pageID, $limit = 0, $approved = true) {

// Make sure the search suggestions are unique.

return array_unique($suggestions->column('Term'));
return $suggestions->column('Term');
}
return array();
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public function getSuggestions($term, $pageID, $limit = 5, $approved = true) {

// Make sure the search suggestions are unique.

return array_unique($suggestions->column('Term'));
return $suggestions->column('Term');
}
}
return array();
Expand Down

0 comments on commit 04766a5

Please sign in to comment.