Configuring Google Custom Search on Drupal 6
This reference documents the default Yale: Centered (Wide) theme. Note the configuration for Drupal 6 sites will depend on the theme that is applied to the site.
For assistance enabling Google Custom Search on a Drupal 6 Site, please contact email@example.com
Note: Before beginning you must have a Google Custom Search engine created and enabled.
Creating the Results Page
- Create a new Basic Page on your D6 site.
- Under Input format, select Full HTML. Under URL path settings, uncheck Automatic alias and enter a URL for the results page (such as ‘search/results’).
- Copy the GCS code (cse.google.com | Setup > Basics > Get code) from <script> tag to </script> tag (including the tags). Paste the copied code into the Body section of the new Basic Page. Beneath the copied code, type the following and then Save the page:
The preceding code will display only the search results (with no included search box). Alternately, the class can be changed to "gcse-search" to include a search box with the results or "gcse-searchbox-only" for just the Google search box. See Google’s documentation on Custom Search elements for more information.
Creating the Search Form
- Create a new Block. Provide a Block description and a Block title (optional). Under Input format, select Full HTML.
- Insert a search form. A sample search form can be seen below:
<form action="/search/results" method="get">
<input type="text" name="query">
The action option should be replaced with the path to the search results page created earlier (be sure to include the leading '/').
Note that the form method must be set to "get" and the input (type text) name parameter must be set to "query".
- Under Show block on specific pages, specify where the page should be displayed before clicking Save.
- Finally, configure the block to be displayed in the desired region.