|
Web Design > Google Search > Add a Search Box Add a Search Box to Your Site Contents:
Create a Basic Search Box You can add a basic search box to your web site to help visitors find content.
Here is an working example of a basic search of the main Columbia site, using the above code: Restrict Your Search by Site: Single Site If you want to restrict your search feature to a specific directory (and its subdirectories), include the following two lines in your form:
<input type="hidden" name="as_dt" value="i"/>
If you don't include these lines, the search feature on your site
will search the entire Columbia collection.<input type="hidden" name="as_sitesearch" value="<yoururl>"/>
Here is an working example of a search restricted to a single site, in this case the Biology Department: Restrict Your Search by Site: Specifying Multiple Sites If you want to restrict your search feature to a more than one specific directory (and its subdirectories), include the following in your form instead of the parameters as_dt and as_sitesearch:
<input type="hidden" name="as_oq" value="<firsturl secondurl>"/>
Here is an working example of a search of multiple sites, in this case SIPA and the World Leaders Forum: Restrict Your Search by Searcher-Selected Sub-Area Use the following code to include a drop-down list of different areas of your site from which people can choose.
<form method="get"
action="http://search.columbia.edu/search">
<input type="text" name="q" alt="Search" value="" maxlength="256" size="32"/> <input type="submit" name="btnG" value="Search" /> <input type="hidden" name="site" value="Columbia"/> <input type="hidden" name="client"value="columbia" /> <input type="hidden" name="proxystylesheet" value="columbia" /> <input type="hidden" name="output" value="xml_no_dtd"/> <input type="hidden" name="filter" value="0"/> <input type="hidden" name="as_dt" value="i"/> <br />Select an area to search: <select name="as_sitesearch"> <option value="url1">Section Name 1 <option value="url2">Section Name 2 </select> </form> For each URL/Name pair, enter a complete URL to limit the search and a label to describe it, e.g.
<option value="http://www.law.columbia.edu/faculty">Faculty Directory
You can include as many options in the drop-down menu as you want, although the sample only shows two. Tip: You will probably want to include an option to search your entire site. Place it first in the list, and it will appear as the default selection:
<option value="http://www.law.columbia.edu">Entire Law School
<option value="http://www.law.columbia.edu/faculty">Law School Faculty Here is an working example of a search with a drop-down menu of options: Search the Law School |
