Want to add a search engine to your Web site but don't know how? Well, today's your lucky day! In this tutorial, find out how to obtain, install and use the popular ht://Dig indexing engine to add powerful, effective search capabilities to your site with minimal time and fuss.
Once the form is submitted, the "htsearch" utility takes over and queries the database to retrieve a list of pages matching the query string. This utility also takes care of generating the result page, as per the formatting parameters specified. In case you'd like to control the appearance of this page, ht://Dig allows you to customize the result page templates as well, though the process is somewhat convoluted.
You can alter the header and footer of the result page by setting the "search_results_header" and "search_results_footer" variables in the configuration file to point to custom header and footer files. Alternatively, simply customize the application's default "header.html" and "footer.html" files, installed to the application's "common" directory.
You can customize the page that appears in case a syntax error is found in a Boolean search, by modifying the file "syntax.html" in the installation's "common" directory. Alternatively, create your own file and tell ht://Dig where to find it by setting the "syntax_error_file" variable in the configuration file.
You can tell ht://Dig to display a custom page if the search produces zero matches, by setting the "nothing_found_file" variable in the configuration file, or by altering the "nomatch.html" template in the installation's "common" directory.
By default, ht://Dig ships with two built-in templates, "builtin-long" and "builtin-short", which are used to display the results found during a search. You can modify the results page to conform to the design of your site by altering these templates, named "long.html" and "short.html" respectively, or use your own templates by setting the "template_map" variable in the configuration file.
All these templates can contain special ht://Dig variables that will dynamically be replaced with actual values when a search is performed.
While on the topic, here's a quick tip: if you're setting up a simple search engine, or if you're pressed for time, I'd advise you to simply modify the default templates that ship with the application, rather than creating new templates and configuring the system to recognize them.