The examples below illustrate how to code search forms that perform search queries against the Google Search Appliance and the campus directory.
Search queries are sent to https://search.uci.edu/
The following inputs are accepted:
Name | Accepted values | Description |
---|---|---|
q | Any string. | (required) The search query |
type | "Web" or "People" | (optional) Indicated the type of search to perform. Searches with type "Web" are routed to the campus search appliance. Searches with type "People" are routed to the campus directory. If no type or a type other than "Web" or "People" is indicated, the search is treated as type "Web". |
collection | Comma-delimited numeric list | (optional) Restricts search results to a defined subset of UCI web properties. Search appliance admins must be notified before this option is used to advise on appropriate value(s). Defaults to all UCI web properties if no value is supplied. |
Code Examples
To perform web searches only
Form actions should point to a centrally-hosted script (searchgate.php) that determines the type of search being performed and directs the query to the appropriate applianceThis example uses minimal markup for a web-only search form.
Code Block |
---|
<form action="https://search.uci.edu/" method="get"> <input name="collection" type="hidden" value="uci_full"/> <label for="search-text">Search</label> <input id="search-text" name="q" placeholder="Search..." type="text"/> <button name="type" type="submit" value="Web">Web<>Go</button> </form> |
Adding an option to search the campus directory
Here we add a second button with a value of "People". That's all... searchgate figures out the rest.
Code Block |
---|
<form action="https://search.uci.edu/" method="get"> <input name="collection" type="hidden" value="uci_full"/> <label for="search-text">Search</label> <input id="search-text" name="q" placeholder="Search..." type="text"/> <button name="type" type="submit" value="Web">Web</button> <button name="type" type="submit" value="People">People</button> </form> |
Specifying a collection
The following example restricts search results to the Official University Policies & Procedures website by adding a hidden input that supples the numeric value for that collection.
Code Block |
---|
<form action="https://search.uci.edu/" method="get">
<input type="hidden" value="17"/>
<label for="search-text">Search</label>
<input id="search-text" name="q" placeholder="Search..." type="text"/>
<button name="type" type="submit" value="Web">Go</button>
</form> |
Styling the search form
...
All non-hidden form inputs must be labeled. In the above examples, this is accomplished by including a <label>
element and associating it with the <input>
by using the <input>
's id
attribute value as the <label>
's for
attribute value. However, this isn't the only way to label a form control; alternate methods are described on the W3C website: Labeling Controls.
Setting search scope
In the above examples, <input name="collection" type="hidden" value="uci_full"/>
instructs the GSA to search against all UCI sites via value="uci_full"
. If you want to restrict the search results returned by the GSA (e.g., search only your site), change the value of this attribute to your desired GSA collection. If you don't know what a GSA collection is or which one to use, then you likely don't have one configured. Contact Todd or Jim to get one set up.