ENG/RUS   Main :: RiSearch :: RiSearch Pro :: RiCoord :: RiMap :: RiSearch PHP :: RiLax :: Forum

Introduction :: Manual :: Order :: License

Main

RiSearch Pro v.3.2 Manual

© S. Tarasov

Template usage

      Script uses template to control design of script output. Template is placed in file "templates/template.htm". It is standard HTML file, which can be opened by every browser. You may look how your page will be displayed and edit it.

      The look of highlighted terms is defined by parameters mark_start è mark_end.

      Template consists of seven sections: "header" and "footer" will be displayed in every case; "results_header", "results_NN" and "results_footer" are displayed in case of successful search; "no_results" is used if no results are found; "empty_query" will be displayed if there is no query supplied.

      Please note, that in case of multidatabase search you need separate "results_NN" section for every database (where NN is database number).

      Each section divided by marks, like this:

 <!-- RiSearch::header::start --> 
You may edit everything between two dividers.

      Template uses several predefined parameters, which will be replaced by results of script work. Here is full list of parameters:

  1.  %data_N%  - value of field N.

  2.  %query%  - query.

  3.  %search_time%  - time used by script to perform search.

  4.  %query_statistics%  - found words statistics (string like - "word1-n1 word2-n2").

  5.  %stpos%  - the starting number for results on this page (starting from 0).

  6.  %rescount%  - total number of found files.

  7.  %next_results%  - links to next pages with results (printed in blocks by 20 pages).

  8.  %prev_page%  - link to the previous page with results (or empty string, if current page is first).

  9.  %next_page%  - link to the next page with results (or empty string, if current page is last).

  10.  %prev_pages%  - link to the previous block of pages with results (or empty string, if current block is first).

  11.  %next_pages%  - link to the next block of pages with results (or empty string, if current block is last).

  12.  %res_num%  - number of results in one page.

  13.  %s%  - sorting type (takes values "N", "1", "2" etc.).

  14.  %stype%  - search type ("AND" or "OR").

Multiple templates

      Script can use several templates to print results. Each additional template should be defined in configuration file:  template_1 => "templates/template_1.htm",   template_2 => "templates/template_2.htm", 

      Use parameter "t=N" (where N is templates number) in query string to use non-standard template for results printing.

Additional template features

      Sometimes printed information should depend on search results. For this purpose conditional operators can be used:

<% IF %condition% %> Print something <% ENDIF %>

information is printed only when condition is true, and

<% IF %condition% %> Print 1 <% ELSE %> Print 2 <% ENDIF %>

in this case if condition is true "Print 1" is printed, and "Print 2" otherwise.

      Conditions (%condition%) can be written like:


%sorting% == "R"     - TRUE, if parameter %sorting% equal "R"
%zones_names% == "News"     - TRUE, if parameter %zones_names% equal "News"
%prev_page% != ""     - TRUE, if parameter %prev_page% NOT equal empty string

      These operators can be used in such way:

<% IF %sorting% == "R" %>(Score: %score%)<% ENDIF %>

- document score will be printed only when results are sorted by relevancy.

      Another operator can perform simple arithmetic operations:

<% DO %> %stpos% + %res_num% <% ENDDO %>

      For example, next code will print links range in current page:

<% DO %> %stpos% + 1 <% ENDDO %>
..
<% IF %next_page% == "" %> %rescount% <% ELSE %><% DO %> %stpos% + %res_num% <% ENDDO %><% ENDIF %>

      Other examples can be found in file "demo_template.htm".

SSI directives

      You may use simple SSI directives in template. Only <!--#include virtual='file'--> is supported.



http://risearch.org S.Tarasov, © 2000-2003