- 🇫🇷France anou Collonges au Mont d'Or
Hello,
searching to filter search results by language, I had hard time to find the right "TAG" for the search exclude query. I put here my solution to filter the search results by language using search_exclude module:
In a [MY–MODULE].module file:
use Drupal\Core\Database\Query\AlterableInterface; /** * Implements hook_query_TAG_alter(): tag search_$type with $type search_exclude_node_search * the TAG part = search_search_exclude_node_search (!!!) * * @return Search results in current language */ function [MY–MODULE]_query_search_search_exclude_node_search_alter(AlterableInterface $query) { $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $query->condition('n.langcode', $language, '='); }
Once you find the TAG, so simple :-)