Services

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 search@yale.edu

Note: Before beginning you must have a Google Custom Search engine created and enabled.

 

Creating the Results Page

  1. Create a new Basic Page on your D6 site.
  2. 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’).
  3. 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:

           <div class="gcse‑searchresults‑only"
                   data‑enableHistory="false"
                   data‑enableImageSearch="false">
           </div>

    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

  1. Create a new Block.  Provide a Block description and a Block title (optional).  Under Input format, select Full HTML.
  2. Insert a search form.  A sample search form can be seen below:

               <form action="/search/results" method="get">
                     <fieldset>
                            <input type="text" name="query">
                            <input type="submit">
                     </fieldset>
               </form>

    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".

  3. Under Show block on specific pagesspecify where the page should be displayed before clicking Save.
  4. Finally, configure the block to be displayed in the desired region.