<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Designing search.htm</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="mnoGoSearch 3.3.9 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="Template operators" HREF="msearch-templates-oper.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" ><!--#include virtual="body-before.html"--><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ><SPAN CLASS="application" >mnoGoSearch</SPAN > 3.3.9 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 10. Searching documents</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="msearch-templates-oper.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="html" >Designing <TT CLASS="filename" >search.htm</TT ></A ></H1 ><P > This section assumes that you are using the <ACRONYM CLASS="acronym" >CGI</ACRONYM > front end. </P ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-respage" >How the search results page is created</A ></H2 ><P >The file template file <TT CLASS="filename" >search.htm</TT > consists of a number of blocks delimited by <ACRONYM CLASS="acronym" >HTML</ACRONYM > comments starting with <TT CLASS="literal" ><!--comment--></TT > and ending with <TT CLASS="literal" ><!--/comment--></TT >. </P ><P >There is a special block <TT CLASS="literal" ><!--variables ... --></TT > which is used to put <SPAN CLASS="emphasis" ><I CLASS="emphasis" >commands</I ></SPAN > to. The other blocks form parts of the output. </P ><P >The blocks <TT CLASS="literal" ><--top--></TT > and <TT CLASS="literal" ><!--bottom--></TT > are always returned to the user as the top and the bottom parts of the output page page respectively. </P ><P >The three blocks <TT CLASS="literal" ><!--restop--></TT >, <TT CLASS="literal" ><!--res--></TT > and <TT CLASS="literal" ><!--resbot--></TT > are displayed to the user in case when a search query produced at least one result. The blocks <TT CLASS="literal" ><!--restop--></TT > and <TT CLASS="literal" ><!--resbot--></TT > are displayed once, while the block <TT CLASS="literal" ><!--res--></TT > is displayed for every found document. </P ><P > Furthermore there is a serie of <SPAN CLASS="emphasis" ><I CLASS="emphasis" >page navigation</I ></SPAN > blocks and the blocks <TT CLASS="literal" ><!--notfound--></TT >, <TT CLASS="literal" ><!--noquery--></TT > and <TT CLASS="literal" ><!--error--></TT >. The latter three blocks are returned occasionally in situations when search did not return any results. </P ><P > Any <ACRONYM CLASS="acronym" >HTML</ACRONYM > code that is outside the pre-defined blocks in <TT CLASS="filename" >search.htm</TT > is completely ignored. </P ><P >The output of <SPAN CLASS="application" >search.cgi</SPAN > consists of these parts, depending on the situation: <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 every results page. For example, <TT CLASS="literal" ><!--navleft--></TT > and <TT CLASS="literal" ><!--navright--></TT > are used to link to the previous and next results pages, while <TT CLASS="literal" ><!--navXXX_nop--></TT > 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 <ACRONYM CLASS="acronym" >HTML</ACRONYM ></A ></H2 ><P >The default <ACRONYM CLASS="acronym" >HTML</ACRONYM > template code provided in <TT CLASS="filename" >search.htm-dist</TT > is ready for use, so you may decide to use it without applying any major modifications. </P ><P >Once you decide to add bells and whistles to your search, you have multiple options. One option is to keep the simple design of <TT CLASS="filename" >search.htm</TT > and 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 frame. </P ><P >Other option is to incorporate your entire design into <TT CLASS="filename" >search.htm</TT >. As soon as you understand the idea of the <SPAN CLASS="emphasis" ><I CLASS="emphasis" >blocks</I ></SPAN > described above, this should be easy to do. </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 <ACRONYM CLASS="acronym" >HTML</ACRONYM > code in the <TT CLASS="literal" ><!--top--></TT > block of <TT CLASS="filename" >search.htm</TT >, up to and including the opening of the main table (<TT CLASS="literal" ><table><tr><td></TT >). If you then put the closing of the main table and the closing tags of the page in the <TT CLASS="literal" ><!--bottom--></TT > block (<TT CLASS="literal" ></table></tr></td></body></html></TT >) 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 <ACRONYM CLASS="acronym" >HTML</ACRONYM > 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 <ACRONYM CLASS="acronym" >HTML</ACRONYM > 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 <TT CLASS="literal" ><!--top--></TT > block, since that is the only block that can draw the page even if there are no results at all. In this case your <TT CLASS="filename" >search.htm</TT > would look like this: </P ><DIV CLASS="informalexample" ><P ></P ><A NAME="AEN5669" ></A ><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 <TT CLASS="filename" >search.htm</TT > 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" ><P ></P ><A NAME="AEN5673" ></A ><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 >Although the modern browsers can handle forms that stretch over different tables, writing this kind of forms abuses the standards and is usually considered as bad <ACRONYM CLASS="acronym" >HTML</ACRONYM >. Unless you really can't avoid it, using this style is not recommended. </P ><P >For example,</P ><DIV CLASS="informalexample" ><P ></P ><A NAME="AEN5681" ></A ><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" ><P ></P ><A NAME="AEN5684" ></A ><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 <TT CLASS="filename" >search.htm</TT > can be changed at will. The default is drop-down menus, but nothing stops you from using radio buttons or hidden input or text boxes. For instance, where <TT CLASS="filename" >search.htm</TT > says </P ><DIV CLASS="informalexample" ><P ></P ><A NAME="AEN5691" ></A ><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" ><P ></P ><A NAME="AEN5694" ></A ><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 the drop-down menu, with <TT CLASS="literal" >20</TT > being the default page size. </P ><P >Note that you can also use the </P ><DIV CLASS="informalexample" ><P ></P ><A NAME="AEN5699" ></A ><PRE CLASS="programlisting" > <input type="hidden" name="XX" value="YY"> </PRE ><P ></P ></DIV ><P >format if you want to set your own default values without allowing the user to change them. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-rellinks" >Relative links in <TT CLASS="filename" >search.htm</TT ></A ></H2 ><P >It might be worth mentioning that <TT CLASS="filename" >search.htm</TT > is parsed by <SPAN CLASS="application" >search.cgi</SPAN > which usually resides in the <TT CLASS="filename" >/cgi-bin/</TT > directory of your Web server. When you open <TT CLASS="literal" >http://site-name/cgi-bin/search.cgi</TT > in your browser, all <SPAN CLASS="emphasis" ><I CLASS="emphasis" >relative</I ></SPAN > links are considered as relative to the <TT CLASS="filename" >/cgi-bin/</TT > directory. Therefore, if you have a file system structure like </P ><DIV CLASS="informalexample" ><P ></P ><A NAME="AEN5712" ></A ><PRE CLASS="programlisting" > /var/www/images/ /var/www/html/ /var/www/cgi-bin/ </PRE ><P ></P ></DIV ><P >the correct relative link from <TT CLASS="filename" >search.cgi</TT > to the images in <TT CLASS="filename" >/images/</TT > will be </P ><P ><TT CLASS="literal" ><img src="../images/image.gif"></TT ></P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="html-searchform" >Adding a small Search form to the other pages of your site</A ></H2 ><P >To add a small search form to any of your pages, you can put the following code: </P ><DIV CLASS="informalexample" ><P ></P ><A NAME="AEN5722" ></A ><PRE CLASS="programlisting" > <FORM METHOD="GET" ACTION="/cgi-bin/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-templates-oper.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >How to write search result templates <A NAME="AEN5107" ></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" >Template operators</TD ></TR ></TABLE ></DIV ><!--#include virtual="body-after.html"--></BODY ></HTML >