<HTML ><HEAD ><TITLE >Designing search.html</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.73 "><LINK REL="HOME" TITLE="mnoGoSearch 3.2 reference manual" HREF="index.html"><LINK REL="UP" TITLE="Searching documents" HREF="msearch-doingsearch.html"><LINK REL="PREVIOUS" TITLE="How to write search result templates " HREF="msearch-templates.html"><LINK REL="NEXT" TITLE="Relevancy " HREF="msearch-rel.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="mnogo.css"><META NAME="Description" CONTENT="mnoGoSearch - Full Featured Web site Open Source Search Engine Software over the Internet and Intranet Web Sites Based on SQL Database. It is a Free search software covered by GNU license."><META NAME="Keywords" CONTENT="shareware, freeware, download, internet, unix, utilities, search engine, text retrieval, knowledge retrieval, text search, information retrieval, database search, mining, intranet, webserver, index, spider, filesearch, meta, free, open source, full-text, udmsearch, website, find, opensource, search, searching, software, udmsearch, engine, indexing, system, web, ftp, http, cgi, php, SQL, MySQL, database, php3, FreeBSD, Linux, Unix, mnoGoSearch, MacOS X, Mac OS X, Windows, 2000, NT, 95, 98, GNU, GPL, url, grabbing"></HEAD ><BODY CLASS="sect1" BGCOLOR="#EEEEEE" TEXT="#000000" LINK="#000080" VLINK="#800080" ALINK="#FF0000" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >mnoGoSearch 3.2 reference manual: Full-featured search engine software</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="msearch-templates.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 8. Searching documents</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="msearch-rel.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="html" >Designing search.html</A ></H1 ><P >This section is assuming that you are using the CGI front end.</P ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-respage" >How the results page is created</A ></H2 ><P >The file <TT CLASS="filename" >etc/search.htm</TT > consists of a number of blocks delimited by HTML comments that start with <!--comment--> and end with <!--/comment-->.</P ><P >The <!--variables--> block is only used by <TT CLASS="filename" >search.cgi</TT >. The other blocks form part of the results output depending on the situation. </P ><P >The blocks <--top--> and <!--bottom--> are always returned to the user as the top and bottom part of the output respectively. </P ><P >There are three series of <!--restop-->, <!--res--> and <!--resbot--> blocks. The first series is returned to users that have requested long results (default), the second one to those that have requested short results and the third one to those that have requested results as URL only. All three blocks must be present in <TT CLASS="filename" >search.htm</TT >. Furthermore there is a series of navigation blocks and the blocks <!--notfound-->, <!--noquery--> and <!--error-->. The latter are returned occasionally instead of results.</P ><P >Any HTML that is outside the pre-defined blocks in search.htm is completely ignored. </P ><P >Thus, the output of <TT CLASS="filename" >search.cgi</TT > will always be something like this: <PRE CLASS="programlisting" > top restop top top top res or notfound or error or noquery resbot bottom bottom bottom (navigation) bottom </PRE > </P ><P >The navigation part is built in the same way, with the elements that pertain to each results page. For example, <!--navleft--> and <!--navright--> are used to link to the previous and next results pages, while <!--navXXX_nop--> is used when there are no more pages in one or either direction. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-yourhtml" >Your HTML</A ></H2 ><P >The simplest HTML is provided ready for use in <TT CLASS="filename" >etc/search.htm-dist</TT >. It is advisable that you use this until your back-end works fine. </P ><P >Once you decide to add bells and whistles to your search, you have two options. One is to keep the simple design of <TT CLASS="filename" >search.htm</TT >, but make it part of a frame set. This way you can add elements such as menus etc in a frame and keep the output of <TT CLASS="filename" >search.htm</TT > in another.</P ><P >The other option is to incorporate your entire design in <TT CLASS="filename" >search.htm</TT >. If you fully understand the "blocks" system described above, this should not be too difficult. The one most important factor is to keep track of elements that need to be opened in one block and closed in another. </P ><P >For example, you might want a page in tables that looks like this: <PRE CLASS="programlisting" > ---------------------------------- | top table | |..................................| | . | |left . | | . | | . main table | |table . | | . | | . | ---------------------------------- </PRE > </P ><P >If you are planning to put your results in the main table, you can put all the HTML code in the <!--top--> block of <TT CLASS="filename" >search.htm</TT >, up to and including the opening of the main table (<table><tr><td>). If you then put the closing of the main table and the closing tags of the page in the <!--bottom--> block (</table></tr></td></body></html>) and leave all other blocks unformatted, you will have the design of your choice and all your results in the right place. </P ><P >In a more complicated design, where you want to format results individually, you can apply the same method as long as you keep track of the opening and closing of HTML elements. You must either open and close them in the same block, or make sure that any possible combination of blocks will result in properly opened and closed HTML tags. </P ><P >What you cannot do without editing the source code, is change the order in which the blocks are parsed. Taking the above example, let's assume that you want your page to look like this: <PRE CLASS="programlisting" > ---------------------------------- | logo banner ads | |..................................| | . | |choices . | | . | | . results | |search . | |button . | | . | ---------------------------------- </PRE > </P ><P >To get this, you need to have everything except the results and navigation in the <!--top--> block, since that is the only block that can draw the page even if there are no results at all. In this case your search.htm would look like this:</P ><DIV CLASS="informalexample" ><A NAME="AEN3501" ></A ><P ></P ><PRE CLASS="programlisting" > <!--variables--> [your configuration] <!--/variables--> <!--top--> <html> <body> <table> <tr colspan="2"> <td>[logo, banner ads]</td> </tr> <tr> <td>[search form]</td> <td> <!--/top--> [all other blocks in search.htm except "bottom"] <!--bottom--> [closing elements like the mnogosearch link and a link to the webmaster] </td> </tr> </table> </body> </html> <!--/bottom--> </PRE ><P ></P ></DIV ><P >The individual blocks can be formatted individually as long as that formatting is closed within each block. Thus, nothing stops you from doing things like </P ><DIV CLASS="informalexample" ><A NAME="AEN3504" ></A ><P ></P ><PRE CLASS="programlisting" > <!--error--> <table> <tr><td bgcolor"red"> <font color="#ffffff"> [error variables] </font> </tr><td> </table> <!--error--> </PRE ><P ></P ></DIV ><P >as long as such formatting is opened and closed properly within the same block. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-forms" >Forms considerations</A ></H2 ><P >Most modern browsers can handle forms that stretch over different tables, but writing such forms is against all standards and is bad HTML. Unless you really can't avoid it, don't do it. </P ><P >For example, </P ><DIV CLASS="informalexample" ><A NAME="AEN3511" ></A ><P ></P ><PRE CLASS="programlisting" > <table> <tr><td> <form> <input type="text" name="something"> <input type="radio" name"button1"> <input type="radio" name"button2"> </form> </tr></td> </table> </PRE ><P ></P ></DIV ><P >is fine, but </P ><DIV CLASS="informalexample" ><A NAME="AEN3514" ></A ><P ></P ><PRE CLASS="programlisting" > <table> <tr><td> <form> <input type="text" name="something"> </tr></td> </table> <table> <tr><td> <input type="radio" name"button1"> <input type="radio" name"button2"> </form> </tr></td> </table> </PRE ><P ></P ></DIV ><P >is <SPAN CLASS="emphasis" ><I CLASS="emphasis" >not</I ></SPAN >.</P ><P >Note that the input forms in search.htm can be changed at will. The default is drop-down menus, but nothing stops you from using radio buttons or hidden input or even text boxes. For instance, where <TT CLASS="filename" >search.htm</TT > says </P ><DIV CLASS="informalexample" ><A NAME="AEN3520" ></A ><P ></P ><PRE CLASS="programlisting" > Results per page: <SELECT NAME="ps"> <OPTION VALUE="10" SELECTED="$ps">10 <OPTION VALUE="20" SELECTED="$ps">20 <OPTION VALUE="50" SELECTED="$ps">50 </SELECT> </PRE ><P ></P ></DIV ><P >you can very well substitute </P ><DIV CLASS="informalexample" ><A NAME="AEN3523" ></A ><P ></P ><PRE CLASS="programlisting" > <input type="radio" name"ps" value="10"> <input type="radio" name"ps" value="20" checked> <input type="radio" name"ps" value="50"> </PRE ><P ></P ></DIV ><P >which will result in three radio buttons instead of a drop-down menu, with "20" as the default and the exact same functionality. What you obviously cannot do is provide multiple-choice menus like <type="checkbox"> or <select multiple>. </P ><P >Note that you can also use the </P ><DIV CLASS="informalexample" ><A NAME="AEN3527" ></A ><P ></P ><PRE CLASS="programlisting" > <input type="hidden" name="XX" value="YY"> </PRE ><P ></P ></DIV ><P >format if you want to set other defaults than the pre-defined and not allow the user to change them. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-rellinks" >Relative links in search.htm</A ></H2 ><P >It might be worth mentioning that <TT CLASS="filename" >search.htm</TT > is parsed from your cgi-bin directory. The position of this directory in relation to your document root is determined by the web server, independently of its actual position in the file system. Almost invariably is http://your_document_root/cgi-bin/ . Since <TT CLASS="filename" >search.cgi</TT > lives in cgi-bin, any links to images etc in search.htm will assume cgi-bin as the base directory. Therefore, if you have a file system structure like </P ><DIV CLASS="informalexample" ><A NAME="AEN3535" ></A ><P ></P ><PRE CLASS="programlisting" > home/ home/your_document_root/ home/your_document_root/img/ home/cgi-bin/ </PRE ><P ></P ></DIV ><P >the correct relative link from <TT CLASS="filename" >search.cgi</TT > to images in img/ would still be </P ><P ><img src="../img/image.gif"></P ><P >despite the fact that it doesn't match the file system structure.</P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-searchform" >Adding Search form to other pages</A ></H2 ><P >To place a search form to any of your pages, please place the following code where you would like the form to be displayed:</P ><DIV CLASS="informalexample" ><A NAME="AEN3544" ></A ><P ></P ><PRE CLASS="programlisting" > <FORM METHOD=GET ACTION="http://path-to-search.cgi"> <INPUT TYPE="text" NAME="q" VALUE=""> <INPUT TYPE="submit" VALUE="Search!"> </FORM> </PRE ><P ></P ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="msearch-templates.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="msearch-rel.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >How to write search result templates <A NAME="AEN3083" ></A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="msearch-doingsearch.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Relevancy <A NAME="AEN3548" ></A ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >