To display a "search form block" (a drupal core block) in a custom theme file

echo module_invoke('search', 'block', 'view', 0);

The above function will return

Array
(
    [content] =><form action="/drupal5/"  accept-charset="UTF-8" method="post" id="search-block-form">

<div><div class="container-inline"><div class="form-item" id="edit-search-block-form-keys-wrapper">
 <input type="text" maxlength="128" name="search_block_form_keys" id="edit-search-block-form-keys"  size="15" value="" title="Enter the terms you wish to search for." class="form-text" />
</div>
<input type="submit" name="op" id="edit-submit" value="Search"  class="form-submit" />
<input type="hidden" name="form_token" id="edit-search-block-form-form-token" value="ac4853e8f1f0280b08a1208def60093e"  />
<input type="hidden" name="form_id" id="edit-search-block-form" value="search_block_form"  />
</div>
</div>
</form>



    [subject] => Search
)

if you want to apply custom css style to your search form block refer
http://drupal.org/node/108467

This is my first snippet will write more in future (thanks to dereline #drupal)

Comments

sstrong’s picture

need to remove the first paren before module_invoke.

echo module_invoke('search', 'block', 'view', 0); 
Kristi Wachter’s picture

Fixed - thanks!

˚ ˚ ˚ ˚ ˚
Kristi Wachter
Drupal consultant, evangelist, and enthusiast

candelas’s picture

this still works in 6.20
if you dont want the label and the search button:

$buscar = module_invoke('search', 'block', 'view', 0);
$buscar[content]= preg_replace("/<label(.*)>(.*)<\/label>\n/i", "", $buscar[content]);
$buscar[content]= preg_replace("/<input(.*)type=\"submit\"(.*)>/i", "", $buscar[content]);
print $buscar[content]

//trying to answer one question for each one that i make.
//this way, drupal will be more friendly and strong