#1906 serach form autocmplete multi terms
This commit is contained in:
@@ -57,11 +57,14 @@ class Base extends ControllerBase {
|
||||
}
|
||||
|
||||
// in case of term id provided restrict the keys to taxo fields
|
||||
if ($this->term) {
|
||||
if ($this->terms && count($this->terms)) {
|
||||
$term_conditions = $this->and_query->createConditionGroup('OR');
|
||||
$term = (int) $this->term;
|
||||
foreach (['tag_tid', 'thesaurus_tid'] as $field) {
|
||||
$term_conditions->addCondition($field, $term);
|
||||
// $term = (int) $this->term;
|
||||
foreach ($this->terms as $term) {
|
||||
$tid = $term->value;
|
||||
foreach (['tag_tid', 'thesaurus_tid'] as $field) {
|
||||
$term_conditions->addCondition($field, (int) $tid);
|
||||
}
|
||||
}
|
||||
$this->and_query->addConditionGroup($term_conditions);
|
||||
|
||||
@@ -265,7 +268,11 @@ class Base extends ControllerBase {
|
||||
\Drupal::logger('materio_sapi')->notice($this->keys);
|
||||
}
|
||||
// get the exacte term id in case of autocomplete
|
||||
$this->term = $request->query->get('term');
|
||||
// $this->terms = $request->query->get('terms');
|
||||
$t = $request->query->get('terms');
|
||||
// $this->terms = strlen($t) ? explode(',', $t) : null;
|
||||
$this->terms = strlen($t) ? json_decode($t) : null;
|
||||
|
||||
// get the filters of advanced search
|
||||
$f = $request->query->get('filters');
|
||||
$this->filters = strlen($f) ? explode(',', $f) : null;
|
||||
@@ -295,7 +302,7 @@ class Base extends ControllerBase {
|
||||
$this->sapiQuery();
|
||||
|
||||
$resp['keys'] = $this->keys;
|
||||
$resp['term'] = $this->term;
|
||||
$resp['terms'] = json_encode($this->terms);
|
||||
$resp['filters'] = $this->filters;
|
||||
// $resp['count'] = $this->results->getResultCount();
|
||||
$resp['count'] = count($this->results['nids']);
|
||||
|
||||
Reference in New Issue
Block a user