I have a D8 site view with exposed filters. I want the selected filters from that view to carry over to the next page's URL.

For example: The page lists software titles. If someone filters on OS, and picks MacOS, the URL of the view page changes from "viewpage" to "viewpage?os=MacOS". I want to make the links in the view change from "drupalpage" to "drupalpage?os=MacOS".

I can't figure out how to add the "?os=MacOS" query string to a link in the view. Is there a way to do that?

1 Answer 1


I think what you needed to get in on your preprocess and pass it to your views.

In a hook_preprocess_views_view() implementation in your theme or module:

$values = $view->getExposedInput();
// for example $values["os"];

Or, you can access the values directly from the views-view.html.twig template:

// Assuming `os` is configured to be the Filter identifier in the 

// view's Filter Criteria exposed filter.
{{ view.getExposedInput.os }}
  • Thanks. I was asking about the filter variables in the URL being passed into the links on the page so they would persist on the next page, and BEF (which we're using) doesn't do anything like that. We did figure out how to do what I needed in the TWIG template for the page by using view.getExposedInput variables there. Works perfectly.
    – DHB
    Sep 25, 2021 at 12:44
  • @DHB thank you very much for your comment. I miss understood the question. I update the answer for you it's a bit late but it could help other drupalist who need something like it in the future :).
    – Yuseferi
    Sep 26, 2021 at 11:49
  • Thank you @Yuseferi! I was actually able to do just that, and it worked exactly as we needed it to.
    – DHB
    Apr 5, 2022 at 17:09
  • @DHB no problem at all. if it works mark it as an correct answer to help peoples in the future please :)
    – Yuseferi
    Apr 6, 2022 at 15:39
  • 1
    Thanks for the tip @Yuseferi. I've marked it.
    – DHB
    Apr 7, 2022 at 17:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.