search filters ok, to be improved on results pertinance
This commit is contained in:
@@ -86,6 +86,18 @@ class Base extends ControllerBase {
|
||||
$this->query->setOption('termid', $this->term);
|
||||
}
|
||||
|
||||
// filter the search
|
||||
if ($this->filters) {
|
||||
$filters_conditions = $this->query->createConditionGroup('OR');
|
||||
foreach ($this->filters as $filter) {
|
||||
$filter = (int) $filter;
|
||||
foreach (['tag_tid', 'thesaurus_tid'] as $field) {
|
||||
$filters_conditions->addCondition($field, $filter);
|
||||
}
|
||||
}
|
||||
$this->query->addConditionGroup($filters_conditions);
|
||||
}
|
||||
|
||||
// Restrict the search to specific languages.
|
||||
$lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
$this->query->setLanguages([$lang]);
|
||||
@@ -137,7 +149,14 @@ class Base extends ControllerBase {
|
||||
// $this->keys = Tags::explode($this->keys);
|
||||
\Drupal::logger('materio_sapi')->notice($this->keys);
|
||||
}
|
||||
// get the exacte term id in case of autocomplete
|
||||
$this->term = $request->query->get('term');
|
||||
// get the filters of advanced search
|
||||
$f = $request->query->get('filters');
|
||||
$this->filters = strlen($f) ? explode(',', $f) : null;
|
||||
// $this->allparams = $request->query->all();
|
||||
// $request->attributes->get('_raw_variables')->get('filters')
|
||||
//
|
||||
$this->offset = $request->query->get('offset') ?? $this->offset;
|
||||
$this->limit = $request->query->get('limit') ?? $this->limit;
|
||||
}
|
||||
|
Reference in New Issue
Block a user