I'm using preprocess_views_view to define some new variables and pass them to a twig template.
In order to define these variables I need to access the exposed filters input values, but I can't seem to figure out how:
function my_modules_preprocess_views_view(&$variables) {
$view = $variables['view'];
// Here I would need to access the exposed filters value
$exposed_filter_value = "the_value";
$variables["foo"] = "Something based on the exposed filters value";
}
I would be very grateful for any clues - cheers!
In a hook_preprocess_views_view()
implementation in your theme or module:
$values = $view->getExposedInput();
// for example $values["color"];
Or, you can access the values directly from the views-view.html.twig
template:
// Assuming `color` is configured to be the Filter identifier in the
// view's Filter Criteria exposed filter.
{{ view.getExposedInput.color }}
我在@Hubert 的解决方案中遇到了问题,并设法让它与:
$variables["searchInputValue"] = $view->exposed_raw_input['query'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.