To group search results and display them in different blocks i want to filter them programmatically with facets.

I found a Solution, where the view is executed only with a new request object.

term = searchword
content = facet field

function theme_preprocess_views_view__search_view__page(&$vars) {
    $view = Drupal\views\Views::getView('search_view_groups');

    $filters = [
        'term' => $vars['view']->getRequest()->query->get('term'),
        'content' => ['bereich:80']

    $request = new Symfony\Component\HttpFoundation\Request($filters);


The code works with params from the real request, but i can't change them in the hook. So i guess i use the wrong hook.

When should i run the filter? Which is the correct hook for that?

Drupal: 8.3.5
facets: 1.x-dev
search_api: 1.3


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.