| ACADEMIC COMPUTING and COMMUNICATIONS CENTER | |||||||||
| ||||||||||||||||||||
Examples and Tutorial | ||||||||||||||||||||
|
The above descriptions are probably not clear without several examples. You can use these examples in several ways:
|
||||||||||||||||||||
| ||||||||||||||||||||
| Example 1 - Bare Minimum | ||||||||||||||||||||
|
HTML Form: example1.html Config File: None
This example shows the bare-bones minimum, taking all defaults.
It has only one general input field. But the form is active, and
you can type in various search words, or a full Verity Language query
if you know the syntax. The two crucial parts are the |
||||||||||||||||||||
| Example 2 - URL Limits and Select Boxes | ||||||||||||||||||||
|
HTML Form: example2.html Config File: None
In addition to a general word query field, this example contains
two
Also, the two |
||||||||||||||||||||
| Example 3 - More Complex Queries | ||||||||||||||||||||
|
HTML Form: example3.html Config File: None This example shows how to make a more complicated query, giving the user the option to AND or OR the search words, and to limit the search to the TITLE field or URL field. In particular, it illustrates generating a single search term using multiple HTML tags. The HTML tags are associated with each other through the use of a common string in the NAME part of the tags. |
||||||||||||||||||||
| Example 4 - Auxiliary Variables and Hidden Fields | ||||||||||||||||||||
|
HTML Form: example4.html Config File: None This examples shows how to set the variables s_maxhits (for changing the max number of returned hits), s_sortby (for changing the order of returned hits), and s_resultsby (for changing the information displayed about each returned hit). It also uses a hidden field to restrict the search to a given set of URLs (ie a given subdirectory tree). |
||||||||||||||||||||
| Example 5 - First Use of Config File | ||||||||||||||||||||
|
HTML Form: example5.html Config File: config5.txt
This is exactly like example 4. The only difference is that the hidden
field is moved from the HTML form to the config file. This is the
first, fairly minimal, use of a config file. The Of course, since a config file is used, the ACTION attribute in the <FORM> tag must now contain the path to this config file. |
||||||||||||||||||||
| Example 6 - Simple Control of Output Format | ||||||||||||||||||||
|
HTML Form: example6.html Config File: config6.txt
Back to the very simple query form, but with use of the config file
to control the output format. This shows the simple use of the
|
||||||||||||||||||||
| Example 7 - Conditional Control of Output Format | ||||||||||||||||||||
|
HTML Form: example7.html Config File: config7.txt
Quite similar to example 6, but three |
||||||||||||||||||||
| Example 8 - Embed HTML Form in Output | ||||||||||||||||||||
|
HTML Form: example8.html Config File: config8.txt Similar to example 7, but the original HTML form is reproduced in the output, so that the user can easily do another search. The key point is that the VALUE attribute is used, along with the $query variable, so that the new default search is identical to the search just completed. Note the tag: <input type=text name="query" value="$query" size=50>The part name="query" identifies the name of
the HTML field, and is used by SearchUIC to generate a query.
It is also used to set the $query internal variable.
Therefore the part value="$query" can make
use of the internal variable, and set the default of this field
to the value of $query, i.e. the value of the previous search.
The key point is that $query is replaced with the value of
the internal variable, after the search is completed, but before the
HTML from the config file is rendered for output. Therefore, by the
time the new HTML form is returned to the browser, this value is
already set to the value from the previous query. You can see this
by Viewing the Document Source on the returned HTML form, and comparing
it with the |
||||||||||||||||||||
| Example 9 - Complicated HTML Form in Output | ||||||||||||||||||||
|
HTML Form: example9.html Config File: config9.txt
Very similar to example 8, but now the embedded HTML form is more complicated.
Instead of just using |
||||||||||||||||||||
| Example 10 - Fixed Search | ||||||||||||||||||||
|
HTML Form: None Config File: None We can pass search parameters to the CGI script through a URL, rather than use an HTML form. Here's a URL that will search for the string fortran, taking most defaults: http://www.uic.edu/htbin/search/SearchUIC?query=fortranThis has limited use by itself, but the idea of using a link to invoke the CGI script, and including the config file, can be quite useful. A better use is illustrated in example 11. |
||||||||||||||||||||
| Example 11 - Search for More | ||||||||||||||||||||
|
HTML Form: example11.html Config File: config11.txt Searches are always limited to a maximum number of hits, determined by s_maxhits. The actual number of hits is returned in the variable $s_nres, which may be equal to or less than $s_maxhits. However, it is not necessary to start the results at number 1. In fact, the first hit starts at s_starthits, and the last hit is returned in $s_stophits. And if there were potentially even more hits to be returned, the variable $s_more is set to + (a plus sign) and the variable $s_next is set to one more than $s_stophits. The upshot is that you can generate a link to search "The Next 10 hits" on your return HTML, using these variables. The URL that generates the "Next 10" link is rather long, although similar in spirit to example 10. Here are the pieces:
|
||||||||||||||||||||
| Example 12 - Look Ma! No HTML File! | ||||||||||||||||||||
|
HTML Form: None Config File: config12.txt That's right, you don't have to have an HTML file. Of course you knew that, because example 10 didn't use one. But in this case, We'll use a link to invoke the config file without doing a search. The config file will detect this, and display the HTML search form, after all. This is similar to example 8, where we embedded the HTML search form in the config file, so that the user could repeat or refine the search easily. Same idea, but in this case, we only need to define the form once in the config file, and skip the standalone HTML form. Here's the URL to get this started: http://www.uic.edu/htbin/search/SearchUIC/depts/accc/webpub/search/config12.txt |
||||||||||||||||||||
| Example 13 - All Together Now | ||||||||||||||||||||
|
HTML Form: None Config File: config13.txt This is a full-featured example and uses most of the tricks discussed. As before, we don't need an HTML file, just a URL: http://www.uic.edu/htbin/search/SearchUIC/depts/accc/webpub/search/config13.txt?xprt=0This example:
|
||||||||||||||||||||
| Example 14 - Debugging | ||||||||||||||||||||
|
HTML Form: None Config File: config14.txt
Yes, you're just about done. But what if the config file doesn't
act act you think it should? First thing to try is set the
http://www.uic.edu/htbin/search/SearchUIC/depts/accc/webpub/search/config14.txt?xprt=0 Of course, the above URL gives the debug response for the search indicated in the URL (in the above case, no search at all). You can test other aspects by putting in different conditions into the URL. For example, to generate a debug response for a search for "fortran", use this: http://www.uic.edu/htbin/search/SearchUIC/depts/accc/webpub/search/config14.txt?xprt=0&query=fortran |
||||||||||||||||||||
| Web Search Forms | Previous: 6 Output | Next: A1 Related Links |
| 2002-6-29 wwwtech@uic.edu |
|