<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Template operators</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="mnoGoSearch 3.3.8 reference manual" HREF="index.html"><LINK REL="UP" TITLE="Searching documents" HREF="msearch-doingsearch.html"><LINK REL="PREVIOUS" TITLE="Designing search.htm" HREF="msearch-html.html"><LINK REL="NEXT" TITLE="Ranking documents " 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" ><!--#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.8 reference manual: Full-featured search engine software</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="msearch-html.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-rel.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="templates-oper" >Template operators</A ></H1 ><P ><SPAN CLASS="application" >mnoGoSearch</SPAN > template language provides a set of operators making it possible to create templates with some logic. </P ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="templates-if" >Conditional operators</A ></H2 ><P ><SPAN CLASS="application" >mnoGoSearch</SPAN > supports a number of conditional operators in search templates: <TT CLASS="literal" >IF</TT >, <TT CLASS="literal" >IFCS</TT >, <TT CLASS="literal" >IFNOT</TT >, <TT CLASS="literal" >IFLIKE</TT >, <TT CLASS="literal" >ELSEIF</TT > (<TT CLASS="literal" >ELIF</TT >), <TT CLASS="literal" >ELSELIKE</TT > (<TT CLASS="literal" >ELIKE</TT >), <TT CLASS="literal" >IFLE</TT >, <TT CLASS="literal" >IFLT</TT >, <TT CLASS="literal" >IFGE</TT >, <TT CLASS="literal" >IFGT</TT >. </P ><P > Comparison is performed case insensitively for the operators <TT CLASS="literal" >IF</TT >, <TT CLASS="literal" >IFNOT</TT >, <TT CLASS="literal" >IFLIKE</TT >, <TT CLASS="literal" >ELSEIF</TT >, <TT CLASS="literal" >ELSELIKE</TT >, and case sensitively for <TT CLASS="literal" >IFCS</TT >. The operators <TT CLASS="literal" >IFLE</TT >, <TT CLASS="literal" >IFLT</TT >, <TT CLASS="literal" >IFGE</TT >, <TT CLASS="literal" >IFGT</TT > perform numeric comparison: less-or-equal, less, greater-or-equal and greater comparison correspondingly. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!IF NAME="Content-Type" Content="application/pdf"> <img src="pdf.png"> <!ELIF NAME="Content-Type" Content="text/plain"> <img src="text.png"> <!ENDIF> <!IFLIKE NAME="URL" CONTENT="http*"> This is an HTTP address <!ELIKE NAME="URL" CONTENT="ftp*"> This is an FTP address <!ELSE> This is an unknown address type> <!ENDIF> </PRE > </P ><P >It is possible to use nested conditional operators. This gives much power for search template construction. You can find some examples in the default template <TT CLASS="filename" >search.htm-dist</TT >. </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="templates-oper-set" >The <SPAN CLASS="emphasis" ><I CLASS="emphasis" >SET</I ></SPAN > operator</A ></H2 ><P >This operator is designed to set a variable value from a constant, from another variable, or from a more complex expression. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!SET NAME="a" Content="Some string"> <!SET NAME="b" Content="Another string"> <!SET NAME="c" Content="$(a)"> <!SET NAME="d" Content="a is '$(a)', b is '$(b)', c is '$(c)'"> </PRE > </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="templates-oper-copy" >The <SPAN CLASS="emphasis" ><I CLASS="emphasis" >COPY</I ></SPAN > operator</A ></H2 ><P >The <SPAN CLASS="emphasis" ><I CLASS="emphasis" >COPY</I ></SPAN > operator calculates the expression given in the attribute <SPAN CLASS="emphasis" ><I CLASS="emphasis" >CONTENT</I ></SPAN >, then treats this value as a name of another variable, whose value is then copied into to the variable with the name given in the attribute <SPAN CLASS="emphasis" ><I CLASS="emphasis" >NAME</I ></SPAN >. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!SET NAME="v1" CONTENT="The first value"> <!SET NAME="v2" CONTENT="The second value"> <!SET NAME="v3" CONTENT="The third value"> <!SET NAME="i" CONTENT="2"> <!COPY NAME="value" CONTENT="v$(i)"> Value="$(value)" </PRE > The above code will display this text: <PRE CLASS="programlisting" > Value="The second value" </PRE > </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="templates-oper-inc" >Arithmetic operators</A ></H2 ><P >Arithmetic operators <TT CLASS="literal" >INC</TT > and <TT CLASS="literal" >DEC</TT > respectively increment and decrement a variable value treating it as an <SPAN CLASS="emphasis" ><I CLASS="emphasis" >integer</I ></SPAN > number. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!SET NAME="a" Content="10">a is $(a) <!INC NAME="a">After increment, a is $(a) <!DEC NAME="a">After decrement, a is $(a) </PRE > </P ><P >Arithmetic operators <TT CLASS="literal" >ADD</TT >, <TT CLASS="literal" >SUB</TT >, <TT CLASS="literal" >MUL</TT > perform integer addition, subtraction and multiplication of two variables specified in the <CODE CLASS="option" >NAME</CODE > and <CODE CLASS="option" >CONTENT</CODE > attributes and write the result back into the variable specified in the <CODE CLASS="option" >NAME</CODE > attribute. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!SET NAME="b" CONTENT="20"> <!SET NAME="a" CONTENT="10"> <!MUL NAME="a" CONTENT="$(b)">a*b=$(a) <!SET NAME="a" CONTENT="10"> <!ADD NAME="a" CONTENT="$(b)">a+b=$(a) <!SET NAME="a" CONTENT="10"> <!SUB NAME="a" CONTENT="$(b)">a-b=$(a) </PRE > </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="templates-oper-loop" >Loop operators</A ></H2 ><P >Three loop operators <TT CLASS="literal" >WHILE</TT >, <TT CLASS="literal" >WHILENOT</TT > and <TT CLASS="literal" >FOR</TT > are available. The <TT CLASS="literal" >FOR</TT > operator was introduced in <SPAN CLASS="application" >mnoGoSearch</SPAN > <TT CLASS="literal" >3.3.0</TT >. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!SET NAME="a" Content="10"> <!WHILENOT NAME="a" Content="0"> a is $(a) <!DEC NAME="a"> <!ENDWHILE> </PRE > <PRE CLASS="programlisting" > <!FOR NAME="a" FROM="10" TO="20">a=$(a)<!ENDFOR> <!SET NAME="from" CONTENT="80"> <!SET NAME="to" CONTENT="90"> <!FOR NAME="a" FROM="$(from)" TO="$(to)">a=$(a)<!ENDFOR> </PRE > </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="templates-oper-misc" >Miscellaneous operators and functions</A ></H2 ><P > <P ><B ><CODE CLASS="function" >URLDECODE</CODE > - decodes an <ACRONYM CLASS="acronym" >URL</ACRONYM >-encoded string.</B ></P > All instances of the <TT CLASS="literal" >%##</TT > encoding in the given string are decoded and the decoded string is written into the variable specified in the <CODE CLASS="option" >NAME</CODE > attribute. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!URLDECODE NAME="decoded" Content="$(url)">URL is $(decoded) </PRE > </P ><P > <P ><B ><CODE CLASS="function" >HTMLENCODE</CODE > - converts special characters to <ACRONYM CLASS="acronym" >HTML</ACRONYM > entities</B ></P >. The conversion rules are:</P ><P ></P ><UL ><LI ><P ><TT CLASS="literal" >&</TT > becomes <TT CLASS="literal" >&amp;</TT ></P ></LI ><LI ><P ><TT CLASS="literal" ><</TT > becomes <TT CLASS="literal" >&lt;</TT ></P ></LI ><LI ><P ><TT CLASS="literal" >></TT > becomes <TT CLASS="literal" >&gt;</TT ></P ></LI ><LI ><P ><TT CLASS="literal" >"</TT > becomes <TT CLASS="literal" >&quot;</TT ></P ></LI ></UL ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!HTMLENCODE NAME="encoded" Content="$(url)">URL is $(encoded) </PRE > </P ><P > <P ><B ><CODE CLASS="function" >EREG</CODE > - Replaces a regular expression.</B ></P > <PRE CLASS="programlisting" > <!EREG NAME="a" CONTENT="string" MATCH="pattern" RESULT="replacement"> </PRE > </P ><P > <CODE CLASS="function" >EREG</CODE > scans the string given in the <CODE CLASS="option" >CONTENT</CODE > attribute for matches to the string given in <CODE CLASS="option" >MATCH</CODE > and stores the matched text into variable given in <CODE CLASS="option" >NAME</CODE > using the <CODE CLASS="option" >RESULT</CODE > value as a replacement pattern. The replacement string can contain substrings in the form <CODE CLASS="varname" >$N</CODE >, where <CODE CLASS="varname" >N</CODE > is a decimal digit <TT CLASS="literal" >0</TT >..<TT CLASS="literal" >9</TT >, which is replaced to the text matching the <TT CLASS="literal" >N-th</TT > parenthesized substring. <CODE CLASS="varname" >$0</CODE > produces the entire contents of matching string. The <CODE CLASS="option" >CONTENT</CODE > string can have references to other variables. </P ><P > <P ><B >Examples:</B ></P > <PRE CLASS="programlisting" > <!SET NAME="str" CONTENT="http://www.host.com/path/file.ext"> <!EREG NAME="a" CONTENT="$(str)" MATCH="^([a-z]*)://([^/]*)/(.*)" RESULT="scheme=$1; host=$2 path+file=$3">$(a) </PRE > will display: <PRE CLASS="programlisting" > scheme=http host=www.host.com path=path/file.ext </PRE > </P ></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-html.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" >Designing <TT CLASS="filename" >search.htm</TT ></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" >Ranking documents <A NAME="AEN5668" ></A ></TD ></TR ></TABLE ></DIV ><!--#include virtual="body-after.html"--></BODY ></HTML >