Print search form in page.tpl.php

Public

Source: http://drupal.org/node/1021902#comment-4274696

</> CopyGet raw version
php
  1. <?php
  2. $block = module_invoke('search', 'block_view', 'search');
  3. print render($block);
  4. ?>

http://drupal.org/node/1021902#comment-4349872
"The most flexible solution I've found is to re-add the $search_box variable. We do that by preprocessing page to include our beloved variable. Just add this snippet to template.php"

</> CopyGet raw version
php
  1. <?php
  2. /*
  3. * Preprocess page.tpl.php to inject the $search_box variable back into D7.
  4. */
  5. function template_preprocess_page(&$variables){
  6. $search_box = drupal_render(drupal_get_form('search_form'));
  7. $variables['search_box'] = $search_box;
  8. }
  9. ?>