Embedding a view for search and redirection I have set up a view for searching using Search API. In my specific setup, I need this search to be context sensitive, i.e. I have several pages /foo/search, /bar/search, ... and these return different results.

Currently, I do this by making a content type which has a field containing the necessary information and additionally a search processor, which alters the query accordingly.

Additionally, I use Twig Tweak to embed the search view in this content type as described here. This works if I load the search with the query string, e.g. localhost/foo/search?search_api_fulltext=something.

My problem is now that if I click the "Apply" button in the search, I am being redirect to the page created by the view. This page is lacking the content type's data and I no longer get the context sensitive search results.

Is it possible to change this behaviour of the view's Apply button or do you know another way this could be implemented?

Thanks!
Following this reply on drupal.org and this answer on SO, I added a hook:

function my_module_views_pre_build(ViewExecutable $view) {
  if ($view-&gt;id() == 'my_view_id') {
    $view-&gt;override_url = Url::fromRoute('&lt;current&gt;');
  }
}


Some of the assumptions in Drupal and the workarounds are so annoying. Days wasted. :(