Simple, Static Search Form for Drupal Sites
If you're trying to make your Drupal site as fast as possible, you might consider using a static HTML file for page not found (404) errors. There are various other solutions that can help make Drupal faster in these situations while still letting you take advantage of Drupal-level redirects and whatnot, but a static page is always the fastest.
You might want to include a search form on your static page. The forms generated by Drupal's core search module are a little tricky to just copy and paste, because the action attribute of the form is always the page on which that the form appears. If you try copy and pasting the HTML of the search form into your static page, submitting the form won't take you to a search results page, and even if it does, the search doesn't happen. Here's a snippet that will work.
<form action="http://example.com/search" method="post" accept-charset="UTF-8">
<div class="form-item">
<label for="edit-keys">Search:</label>
<input type="text" id="edit-keys" name="keys" value="" size="20" maxlength="255" class="form-text">
<input id="edit-submit" name="op" value="Go" type="submit" class="form-submit">
</div>
</form>
I've left some of Drupal's classes and such in there, and stripped many out. The important parts to keep are the form's action value (which you'll need to update), the form method attribute, and the text field's name value (keys). Other than that, you can modify it to your heart's content.
The trick here is to change the action attribute to example.com/search (changing example.com to your own site location, obviously). This works if you're using Drupal's core search module or Apache Solr. I expect it should work with Search API as well, though I haven't tried that yet. Search module will figure out what the active search engine is on your Drupal site, and forward the request to that search engine, passing the search key(s) along with it.
This static form HTML could be placed anywhere you want people to be able to search your Drupal site, even from a WordPress site!
Comments
So awesome! Thanks a million for this!!! Cheers Kevin