I am making a theme and I am currently attempting to theme the search box.

The default search box is as follows:

<input type="text" maxlength="128" name="search_theme_form" id="edit-search-theme-form-1" size="15" value="" title="Enter the terms you wish to search for." class="form-text" />

How do I remove the following?

  1. size="15"
  2. class="form-text"

I am assuming that I have to go through the template.php file, however, I cannot find any helpful suggestions in the articles on how to theme the search box.

P.S. If somebody could also tell me how to get rid of the label right above the textbox, that would be greatly appreciated.

Comments

hansroberto’s picture

The easiest way is to overide the search-theme-form.tpl. In that file you can control both size and label.

knpwrs’s picture

I'm still not seeing how exactly to do this...

I have the search-theme-form.tpl.php in my theme's folder

What code should I use to get the alterations I want?

shadcn’s picture

in the tpl file you can rewrite the whole html output for the search box and in your case omit the size..etc

Steps:

Add this to template.php in your theme folder

<?php
function phptemplate_search_theme_form($form) {
  /**
   * This snippet catches the default searchbox and looks for
   * search-theme-form.tpl.php file in the same folder
   * which has the new layout.
   */
  return _phptemplate_callback('search-theme-form', array('form' =&gt; $form));
}
?>

then in search-theme-form.tpl.php put your search box as you want it to be

eg

<input type="text" maxlength="128" name="search_theme_form_keys" id="edit-search_theme_form_keys" size="25" value="" title="Enter the terms for which you wish to search." class="form-text" />
<input type="image" src="<?php echo base_path() . path_to_theme() . "/images/search.png"; ?>" name="op" id="edit-submitpic" value="Search" />
<input type="hidden" name="form_id" id="edit-search-theme-form" value="search_theme_form" />
<input type="hidden" name="form_token" id="a-unique-id" value="<?php print drupal_get_token('search_theme_form'); ?>" /> 

Now anywhere you put <?php print $search_box; ?> in your page.tpl.php, the search box you write will be rendered.

lets see if this work
thanks