Site Wide Search Engines  

Support Topics: Site Wide Search Engine: How to: Make a customer ht://Dig search form

The primary interface to ht://Dig is through a standard HTML form. When the form is submitted, ht://Dig will take values from the form and perform the actual search. The search can be modified in many ways with either hidden input fields or other HTML form tags. Study the examples to get a feel of what things are possible.

The HTML form is expected to contain at least an input text field named "words". This is where the user will enter the search words. Other values are also recognized but have appropriate defaults in case they are not used. Required values are in red :




"words" : The words the user enters for their search. This is what ht://Dig will look for in the index databases.

<input type="text" size="30" name="words" value="">




"method" : This can be one of "and", "or", or "boolean". It determines what type of search will be performed. It is quite useful to make this item a drop down menu so the user can select the type of search at search time.



<select name=method>
<option value=and>All
<option value=or>Any
<option value=boolean>Boolean
</select>





"config" : Specifies the name of the configuration file ht://Dig uses to know what site it is supposed to search and what resluts templates it should use for output. Usually this is simply the top most URL of your website and is almost always a hidden form value:

<input type=hidden name=config value="www.yourdomainname.com">




"exclude" : This value is a pattern that all URLs of the search results cannot match. Usually left blank, but can be used either in a pull-down menu or hidden input field as a way of excluding portions of your site from search results.

<input type=hidden name=exclude value="">

If you wanted to exclude all files in a directory called "notpublic", or files that had the word "notpublic" in their name, you would use this:

<input type=hidden name=exclude value="notpublic">




"restrict" : The opposite of "exclude". This value is a pattern that all URLs of the search results will have to match. This can be used to restrict the search to a particular subtree or subsection of your website. Usually left blank, but can be used either in a pull-down menu or hidden input feild as a way of restricting the search to portions of your site.

<input type=hidden name=restrict value="">

If you wanted to restrict the search to a subsection of your site in a folder called "music", or files that had the word "music" in their name, you would use this:

<input type=hidden name=restrict value="music">

or as a pulldown menu in your form:



<select name=restrict>
<option value=music>Tunes
<option value=movies>Flicks
<option value=computers>Propeller-headish
</select>





"format " : This specifies the name of the template to display the search results in. There is currently only one format template included called "mac-find", but you can use up to two more templates (called "short" and "long"). The format value can be specified as either a hidden input field or a drop down menu if you want your user to select from a variety of search result output options.

<input type="hidden" name="format" value="mac-find">

If you wish to make one or two of the other format options available you first need to make the other templates. Make a copies of "mac-find.html" called "short.html" and/or "long.html". Modify the templates using a text editor according to the instructions found in "mac-find.html" then upload them into your "search" directory. To make the other format options you would use a pull-down list in your the search form:



<select name=format>
<option value=short>Dinky
<option value=mac-find>Normal
<option value=long>Gargantuan
</select>





"keywords" : Used to specify a list of required words that have to be in the documents. This list of words is added to the normal words value using logical "and"s. An example use for this value is to make it a drop down menu with a limited set of predetermined categories or keywords to restrict the search. This can be very useful for very structured pages. Note that the words may appear anywhere in the document. The scope of these required words is not limited to words in META tags with the "keywords" or "htdig-keywords" property, despite what the parameter name may suggest.




"matchesperpage" : Specifies how many matches will be displayed on each page of results. The default is 10. Since this value has to be a number, it either needs to be set using a hidden input field or a with a drop down menu.



<select name=matchesperpage>
<option value=10>10 per page
<option value=20>20 per page

Support Topics

Blogs
Calendars
E-Commerce
Email
Form to Email
Guestbooks
Hit Counters
MacHighway Banners
Mailing Lists
Message boards and Forums
PERL
PHP & MySQL
Security
Site Wide Search Engines
Spam
SSL
Traffic Reports
Uploading / Publishing
Video
WebDAV