The WDC developed a few tools to make adding search easier. Using Google Co-op, we created a Custom Search Engine (CSE) that searches www.csulb.edu and daf.csulb.edu. Other servers can be added and address patterns can be excluded. On top of this, we created a javascript library and html snippets that can be dropped onto any page.
Drop these two script libraries into the head section of any page where you have a searchbox or the results (they must be in this order):
<script type="text/javascript" src="http://wdc.csulb.edu/depot/js/wdccore.js"></script>
<script type="text/javascript" src="http://wdc.csulb.edu/depot/js/google_cse.js "></script>
Include this file in the body of any page with a searchbox:
http://www.csulb.edu/divisions/af/wdc/services/web/search/searchbox.htm
and this file in the body of any page where you want search results to show up:
http://www.csulb.edu/divisions/af/wdc/services/web/search/searchresults.htm
N.b.: It's a good idea to have a search box on the results page.
The first thing you probably want to do is change where the search results show up. While we like our site, we realize that your users might prefer some continuity. So, on the page where you have your searchbox, you want to override the default location of the results page. To do this, add the following snippet to the head section of your page after the line importing the google_cse.js library. (Don't forget to replace the bold url with your own path.)
<script type="text/javascript">
<!--//
if(window.wdc && window.wdc.googleCSE){
window.wdc.googleCSE.resultsURL = '/depts/enrollment/search/';
}
//-->
</script>
Best practise is to point to a directory so that you can change the default handler in the future, but there's no technical reason you can't use any URL. For instance, if you look at the source on our example page, you'll see that we point to an .html file.
Virutally any configuration setting used by the script is available to you simply by overriding the default value. Look at the code and ask if you need help interpreting it.
Other than setting the results page, the most important customization you can make is defining which of Google's CSE's you want to use. We set up a CSE that serves our needs. You can set up your own or use somebody else's engine by pointing to it. Here's how. Each CSE is defined by a unique key; change the key, change which search engine you're using. Use the following snippet, replacing the key in bold with another.
<script type="text/javascript">
<!--//
if(window.wdc && window.wdc.googleCSE){
window.wdc.googleCSE.cx = '013231838821823520426:f4dg3j1yiy0';
}
//-->
</script>
Here are two more keys. Wonder what you search if you use them?
N.b.: these overrides must be defined after you've imported the script libraries.
To find out what people are searching for, check the logs for the web server that delivers your results page (another good reason not to use the default WDC page for your results). You should be able to see a line for each search containing a query string like this one:
search/?cx=013231838821823520426%3Af4dg3j1yiy0&cof=FORID%3A11&sa=Search&q=police
The search term is in there somewhere.
N.b.: different web servers have different logging options and some might not log the query string.