Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR Searching both Title and Filename in AssetAdmin (fixes #7013, s…

…ee pull request #71)
  • Loading branch information...
commit 363dc9a4a9bd3c4b1eceee9941585b9eac49ca67 1 parent 57d7655
@chillu chillu authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 code/controllers/AssetAdmin.php
View
12 code/controllers/AssetAdmin.php
@@ -86,9 +86,21 @@ public function init() {
public function getList() {
$folder = $this->currentPage();
$context = $this->getSearchContext();
+ // Overwrite name filter to search both Name and Title attributes
+ $context->removeFilterByName('Name');
$params = $this->request->requestVar('q');
$list = $context->getResults($params);
+ // Re-add previously removed "Name" filter as combined filter
+ // TODO Replace with composite SearchFilter once that API exists
+ if(isset($params['Name'])) {
+ $list->where(sprintf(
+ '"Name" LIKE \'%%%s%%\' OR "Title" LIKE \'%%%s%%\'',
+ Convert::raw2sql($params['Name']),
+ Convert::raw2sql($params['Name'])
+ ));
+ }
+
// Always show folders at the top
$list->sort('(CASE WHEN "File"."ClassName" = \'Folder\' THEN 0 ELSE 1 END), "Name"');
Please sign in to comment.
Something went wrong with that request. Please try again.