I'm using exposed filters in a Drupal 7 site. I'd like to make the selected items from those filters part of the titles. Is there a way I can get the text value of those selected filters and use that text as part of the title?

Settings are as allowed:

enter image description here

I'm also using Better Exposed Filters in this view.

2 Answers 2


A also have this question. But now I'm trying this module: https://drupal.org/project/exposed_filter_data? And this module is not working for me.

I found this:

 * @param type $vars
function MYTHEME_preprocess_views_view(&$vars) {
  if ($vars['view']->name == 'viewName') {
    // get var from GET
    $obj_type = $_GET['obj_type'];
    if (isset($obj_type)) {
      // obj_type is the taxonomy term, get taxonomy term name
      // if taxonomy term have parents
      $tax_parent = taxonomy_get_parents_all($obj_type);
      if (isset($tax_parent[1])) {
        // add parent name to taxonomy term name
        $tax_name =  $tax_parent[1]->name . ', ' . $tax_name;
      //update title
      $vars['view']->build_info['title'] = $tax_name;

And this is working!

  • You can also use $vars['view']->exposed_input which gives the same data as $_GET but only contains exposed input related items, which is better if you want to loop over multiple filters and/or avoid hardcoding vocabulary machine names (it's worth mentioning that obj_type in this example code is an example vocabulary machine name). Commented Jul 4, 2017 at 20:39

(Yes, I know this is an old question, but better late than never?)

If you're wanting to use the exposed filter settings as part of the <title> tag, you can do something similar to:

function hook_process_html(&$variables) {
  if (!empty($variables['head_title']) && $uri = request_uri()) {
    $variables['head_title'] .= " ($uri)";

If you were wanting to change the view title as it appears on the page, it's best done in preprocess_views_view() as mentioned by VVS.


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.