How to get the input value with preprocess from a Fulltext Search Filter exposed form For Drupal 7 I found a workaround to a similar situation here, when combining Core search block forms and search api contextual filters. This &quot;workaround&quot; won't work when using Search API, if you don't want the Contextual Filter in your view.
My current setup:
I am using Search API, with a database server, and displaying the results with a Views page. I am using Search: Fulltext search (exposed) and Exposed form in block:Yes for the search block form.
What I am trying to achive:
I would like to put what was searched for in the Header of the view, and also at the top of No Results Behavior like this:
&quot;You searched for bananas&quot;
The problem:
When using Search: Fulltext search (exposed), the replacement patterns for the input value are not available in the Global Text Area. They are only available by adding a Fulltext Search Contextual Filter. There is an issue for this with a patch for Drupal 8 here.
My question:
Is there a views_pre_render or some other hook that can be used for the Header or No Results region to output the value that was input into the Search: Fulltext search (exposed) form?
There is a dev module to create a token, but it only works for the Results Summary.
Maybe not exactly what you're asking for, but the one way to approach this is to use hook_preprocess_views_view(&amp;$variables) and modify the contents of the header, or add a variable containing the string you want and then it in above/below the header in a views-view.tpl.php template override. If the search string isn't available through $variables, you can probably grab it from the url since it's likely included as a query string.
To get the query string from the url and add it to the template variables you'd do something like the following in your module or theme:
/**
 * Implements hook_preprocess_hook()
 */
function my_module_preprocess_views_view(&amp;$variables) {
  // Get the query string from the url.
  // it will be on something like ?the_search_string=big+banana.
  $search_string_raw = $_GET['the_search_string'];
  
  // Decode the url to remove special chars
  $search_string_decoded = urldecode($search_string_raw);

  // Add it to $variables so it's available in views-view.tpl.php
  $variables['search_string'] = $search_string_decoded;
}

This will make the search_string available in views-view.tpl.php. You can then print it in there with
&lt;?php if($search_string): ?&gt; 
  &lt;?php print $search_string ?&gt;
&lt;?php endif; ?&gt;

// or

&lt;?php

if($search_string) {
  print $search_string;
}

To clarify how hook_preprocess_hook works -- the first &quot;hook&quot; is your module name, and the second is the name of the template that you're targeting. Since we are targeting views-view.tpl.php, we use hook_preprocess_views_view.
In general, the easiest way to get started inspecting php variables is to dump them to the screen. For Drupal 7, I'd recommend installing https://www.drupal.org/project/kint on your site. This will let you print variables to the screen to help you dig into their values and see what's in there. You'd do like:
function my_module_preprocess_views_view(&amp;$variables) {
  kint($variables);
  // or
  kpr($variables['header'])
}

Then you can see what's actually inside of $variables and grab/modify the values in there.