You are here

7 August 2011

This snippet shows how to change page title on search page. For this example the title will be the content of search box(search string).

Source code viewer
  1. function theme_preprocess_page(&$variables) // don't forget to change hook name
  2. {
  3. if(arg(0) == 'search')
  4. {
  5. // get the search string
  6. $default_value = $variables['page']['content']['system_main']['search_form']['basic']['keys']['#default_value'];
  7. // if you have searched something then change the title
  8. if(!empty($default_value)) drupal_set_title($default_value);
  9. }
  10. }
Programming Language: PHP