Sample external search boxes

Link to XML file of databases and database codes in Webfeat

This file is constantly updated as changes to our list of databases included in webfeat changes:
http://search4.webfeat.org/cgi-bin/datasources.pl?clientid=cornell

Code for external search box

In <HEAD> section of the page:

<script language="JavaScript" src="http://wfsearch.webfeat.org/clients/cornellu/js/cornellu.js"   ></script>
<script language="JavaScript" src="http://wfsearch.webfeat.org/js/wf3library.js"   ></script>
<script language="JavaScript" src="http://wfsearch.webfeat.org/clients/cornellu/js/cornelluCustom.js"   ></script>

Anywhere in the <BODY> you want the form to appear:

<script>
function changeCatName() {

    var i = document.wfform.Databases.selectedIndex;
    var DBCat = document.wfform.Databases[i].id;
    var DBCatNew = DBCat.replace(/&/g,'%26');

 document.wfform.catName.value = DBCatNew;
}
</script>

<form action="http://wfsearch.webfeat.org/clients/cornellu/cornell_auth.asp" method="get" name="wfform">
<input type="hidden" name="Command" value="Search">
<input type="hidden" name="Client_ID" value="cornellu">
<input type="hidden" name="noserial" value="1">
<input type="hidden" value="JS" name="format">
<input type="hidden" value="js" name="rtmpl">
<input type="text" name="wf_term1" id="wf_term1" value="">
<input type="hidden" name="wf_field1" value="wf_keyword">
<!-- You can change the value here to create a link that will take you back to a particular page-->
<input type="hidden" name="catName" value="General">
<!-- Adding outside field to keep this query separate from ones from main page -->
<input type="hidden" name="outside" value="YES">

      in
<!-- Here is where you add the databases and categories you would like searched.  The database codes
(e.g. wf_ebscoxml_aph) can be found in the excel spreadsheet linked at the bottom of the page.
This code is for an advanced search which includes a dropdown list of categories to search.
See below for a simple search box option. -->

<select name="Databases" id="Databases" onChange="changeCatName()">
     <option value="wf_ebscoxml_aph,wf_artindexretro" id="General">General</option>
     <option value="wf_ebscoxml_aph,wf_anthroplus" id="Social Sciences and Area Studies">Social Sciences and Area Studies</option>
     <option value="wf_artindexretro" id="Arts %26 Humanities">Arts & Humanities</option>
 </select>
<input type="submit" name="Submit" value="Search" class="button" />
</form>

<!-- END of code -->

---------------------------------


For a simple search box option

In the above code replace:

<select name="Databases" id="Databases" onChange="changeCatName()">
     <option value="wf_ebscoxml_aph,wf_artindexretro" id="General">General</option>
     <option value="wf_ebscoxml_aph,wf_anthroplus" id="Social Sciences and Area Studies">Social Sciences and Area Studies</option>
     <option value="wf_artindexretro" id="Arts %26 Humanities">Arts & Humanities</option>
 </select>

with:

<input type="hidden" name="Databases" id="Databases" value="wf_ebscoxml_aph,wf_artindexretro,wf_anthroplus" />

CommonSpot Intricacies

Where's my <head>?
The CommonSpot templating system does not provide straightforward access to the <head> of your published pages. When developing your base template you may have noticed that you were essentially providing code which CommonSpot would then dump in the <body> of your page.

Fortunately, CommonSpot does provide a way to inject code into the <head>. For this you must use a file called template-basepage.head located in /templates. If this file does not exist, create it.

Here's what you'll want to add to template-basepage.head:

<cfoutput>
	<script type="text/javascript" src="http://wfsearch.webfeat.org/clients/cornellu/js/cornellu.js"></script>
	<script type="text/javascript" src="http://wfsearch.webfeat.org/js/wf3library.js"></script>
	<script type="text/javascript" src="http://wfsearch.webfeat.org/clients/cornellu/js/cornelluCustom.js"></script>
</cfoutput>

Please note: <cfoutput> tags are required by CommonSpot for anything you actually want sent to the browser

Every page on your site will now call this Webfeat JavaScript.  If you would like to limit this call to only certain pages/areas of your site, you could use CommonSpot's metadata within a <cfif>. Something along the lines of:

<cfif Request.Page.Title IS "Find It">	Webfeat <head> JavaScript calls here.</cfif>

This would restrict the Webfeat JavaScript to be called only a page titled "Find It". You can download a list of available CommonSpot Variables here: cspot_variables.doc

The form
There are several options for implementing the actual <form> which will act as the custom Webfeat search box. I chose to avoid using a CommonSpot supplied element such as the "Simple Form", and instead created a custom-script that could be placed on any page utilizing CommonSpot's "Custom Script Element".

A Custom Script Element essentially allows the developer to place any Coldfusion code directly on a page. Here's what my element contained:

<cfoutput>
	<script>
	function changeCatName() {
    		var i = document.wfform.Databases.selectedIndex;
    		var DBCat = document.wfform.Databases[i].id;
		var DBCatNew = DBCat.replace(/&/g,'%26');
		document.wfform.catName.value = DBCatNew;
	}
	</script>

	<form action="http://wfsearch.webfeat.org/clients/cornellu/cornell_auth.asp" method="get" name="wfform">
		<input type="hidden" name="Command" value="Search">
		<input type="hidden" name="Client_ID" value="cornellu">
		<input type="hidden" name="noserial" value="1">
		<input type="hidden" value="JS" name="format">
		<input type="hidden" value="js" name="rtmpl">
		<input type="text" name="wf_term1" id="wf_term1" value="">
		<input type="hidden" name="wf_field1" value="wf_keyword">
		<input type="hidden" name="catName" value="General">
		<!-- Adding outside field to keep this query separate from ones from main page -->
		<input type="hidden" name="outside" value="YES">

		in

		<select name="Databases" id="Databases" onChange="changeCatName()">
			<option value="wf_ebscoxml_aph,wf_artindexretro" id="General">General</option>
			<option value="wf_ebscoxml_aph,wf_anthroplus" id="Social Sciences and Area Studies">Social Sciences and Area Studies</option>
			<option value="wf_artindexretro" id="Arts %26 Humanities">Arts & Humanities</option>
		</select>
		<input type="submit" name="Submit" value="Search" class="button" />
	</form>
</cfoutput>

Please Note: You can create a new custom script element by creating a new coldfusion document in /customcf. It will then be available in the CommonSpot browser interface when selecting which custom script element you would like to use at a specified lcoation.

Attachments

  File Modified
Microsoft Excel Sheet cornellwfcodes01192007.xls Cornell DB codes as of 01/19/2007 Jan 19, 2007 by 00d4eab94afcfd33014afd06a464517c
Microsoft Word 97 Document cspot_variables.doc Listing of CommonSpot Variables Jan 29, 2007 by 00d4eab94afcfd33014afd067e67023e
  • No labels