Drupal 6, Theming Search Box

In this tutorial i will try to explain how to modifiy default search box provided by Drupal module “Search“, this one of many other methods and i think it’s the simplest way.

First of all you’ll need to enable it from admin>build>modules interface then associate it to a region.

Creating theme file

First of all create a file on you theme directory called : ‘search-block-form.tpl.php‘ which is a copy of template file of search box module, the problem whith drupal generated forms are the hidden fields and input file names so we need to pay attention to them :

// $Id: search-block-form.tpl.php,v 1.1 2007/10/31 18:06:38 dries Exp $
<div class="container-inline">
    //Default form call.
    //print $search_form;
<!-- input type text with correct name search_block_form -->
  <input name="search_block_form" type="text" class="keywords" id="edit-search-theme-form-l" maxlength="50" value="Search..." />
<!-- action name "op" -->
<input name="op" type="image" src="<?= url(path_to_theme() . '/images/search.gif', array('absolute' => true)) ?>" class="button" />

    //hidden values !important
    print $search["hidden"];

That’s all ! there’s an interesting forum topic where you can find other methods like preprocess functions etc. :

One Reply to “Drupal 6, Theming Search Box”

Leave a Reply