Friday, 29 July 2011

Adding search to the site

One of the comments that came out from the user's survey was about searching the 'Tube Map'.

   3.  Perhaps a search box on this page that users could use to quickly locate the item on the map would complement the site.

A partial solution was to add a search, that search the site. this has been achieved using Google Custom Search to the site (see below)

To create the search, you need a Google account and then go to

Create a new Custom Search Engine and decide what sites you want to include, the name of the search and whether you want to pay. 

For this project I went for the free/standard edition option which means there will be adverts, as well as the search results from the site. 

When you include the sites to search the format does matter to get it to search the whole you will need to put * at the end, so for example* to search all of

When you click next you get taken to a screen that enables you to select the look of the search box and test it out as shown below.

If you happy with it clicking next will take you to a page with JavaScript code you need. This code add to your pages where ever you want the search.

<div id="cse" style="width: 100%;">Loading</div>
<script src="" type="text/javascript"></script>
<script type="text/javascript">
  google.load('search', '1', {language : 'en', style : google.loader.themes.GREENSKY});
  google.setOnLoadCallback(function() {
    var customSearchControl = new'<this bit changes for each customised search>');
  }, true);

If you can put up with the adverts, this is a solution to the problem of allowing the user to search the site whilst being free.

This work has been supported by funding from JISC. The site can be viewed at or Survey about this material can be found at: please feel free to fill it in or

No comments:

Post a Comment