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 www.sustainablity.net site (see below)




To create the search, you need a Google account and then go to http://www.google.com/cse/


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 http://www.web-sustainablity.net/* to search all of http://www.web-sustainablity.net/.


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="http://www.google.com/jsapi" 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 google.search.CustomSearchControl('<this bit changes for each customised search>');
    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    customSearchControl.draw('cse');
  }, true);
</script>





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 https://sites.google.com/site/emknorg/ or http://www.web-sustainablity.net/emkn/ Survey about this material can be found at: http://www.eSurveysPro.com/Survey.aspx?id=67775a0a-336f-45a5-a222-2f1a6615752c please feel free to fill it in or http://www.eSurveysPro.com/Survey.aspx?id=cec22f0a-e467-4c15-a319-74d96bb8ed9d

No comments:

Post a Comment