Insert Search Form in page.tpl.php

Public

Insert Search Form in page.tpl.php

</> CopyGet raw version
php
  1. The Drupal 7 page.tpl.php doesn't have the $search_box variable anymore. However you can add it in a preprocess function in your template.php:
  2.  
  3. <?php
  4. /*
  5.  * Preprocess page.tpl.php to inject the $search_box variable back into D7.
  6.  */
  7. function MYTHEME_preprocess_page(&$variables){
  8. $search_box = drupal_render(drupal_get_form('search_form'));
  9. $variables['search_box'] = $search_box;
  10. }
  11. ?>
  12.  
  13. Then you just need to print the variable in your page.tpl.php:
  14.  
  15. <?php print $search_box; ?>