Use data from exposed filter taxonomy term to display as title of page

Public

Field obj_type (have taxonomy terms) in exposed filter.

</> CopyGet raw version
php
  1. /**
  2.  * THEME_PREPROCESS_VIEWS_VIEW
  3.  * @param type $vars
  4.  *
  5.  */
  6. function MYTHEME_preprocess_views_view(&$vars) {
  7. if ($vars['view']->name == 'viewName') {
  8. // get var from GET
  9. $obj_type = $_GET['obj_type'];
  10. if (isset($obj_type)) {
  11. // obj_type is the taxonomy term, get taxonomy term name
  12. $tax_name=taxonomy_term_load($obj_type)->name;
  13. // if taxonomy term have parents
  14. $tax_parent = taxonomy_get_parents_all($obj_type);
  15. if (isset($tax_parent[1])) {
  16. // add parent name to taxonomy term name
  17. $tax_name = $tax_parent[1]->name . ', ' . $tax_name;
  18. }
  19. //update title
  20. $vars['view']->build_info['title'] = $tax_name;
  21. }
  22. }