I would like to add a search form to the front page. I've added this to my template.php:

function my_theme_preprocess_page(&$variables){
   $search_box = drupal_render(drupal_get_form('search_form'));
   $variables['search_box'] = $search_box;

I've added this to my page.tpl.php:

<?php print $search_box; ?>

After viewing my site I do see the search form but get this error:

Strict warning: Only variables should be passed by reference in denta_quest_preprocess_page() (line 142 of C:\xampp\htdocs\drupal\themes\my_theme\template.php).


Your probably getting the warning because the function takes its argument by reference and to pass a variable by reference it needs to be defined. You're passing a function call which isn't a variable.

Try the following...

$search_form = drupal_get_form('search_form');
$search_box = drupal_render($search_form);
$variables['search_box'] = $search_box;
  • It didn't work, I was able to see the search form but I'm still getting a warning. – Nick Dec 18 '12 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.