Displaying Search form Block in a custom theme file

Last modified: January 3, 2009 - 18:42

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

<?php
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)

 
 

Drupal is a registered trademark of Dries Buytaert.