Main
RiSearch Pro v.3.2 Manual
© S. Tarasov
Terms highlighting
In search results script show the title of document, short description
and URL. The exact look of results page is configurable.
The search terms are highlight in page description. Script can
form the page description in two ways.
Page description is stored in index database. You may control
the length of stored description and the number of characters,
which will be shown in results. For example:
stored_descr_size => 512,
descr_size => 256,
In this case first 512 bytes of page will be stored in database.
After search is done, script will display 256 bytes with biggest number of
searched terms.
If command read_file_from_local_disk => "YES", is used,
script will attempt to read the file from local disk first
(for that in page URL the string base_url is changed to base_dir).
If file is opened successfully, tags will be stripped and script
will display the string with length $descr_size and with biggest number
of searched terms. If script fails to open file, stored description is shown.
The look of highlighted terms is defined by parameters
mark_start è mark_end .
Cached copies of documents
There is also other way to highlight found terms - if a link "Show terms" appears
next to page description, highlighted copy of the document will be shown there.
Normally script gets required URL via HTTP, but you have option to store
copies of all indexed documents inside index. Set "enable_page_cache"
parameter in configuration file to enable cache. Cached copies will be compressed
to save hard disk space if you set "compress_cache" parameter
(installed module Compress::Zlib is required for this option).
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.
Template consists of seven sections: "header" and "footer" will be displayed
in every case; "results_header", "results" 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.
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:
%query%
- query.
%search_time%
- time used by script to perform search.
%query_statistics%
- found words statistics (string like - "word1-n1 word2-n2").
%stpos%
- the starting number for results on this page (starting from 0).
%url%, %title%, %description%, %date%
- URL of found file, title, description and "last modified" date.
%enc_url%
- encoded URL.
%short_url%
- short URL (if "url_length_limit" is set in config file).
%size%
- size of document (bytes).
%ksize%
- size of document (kilobytes).
%score%
- page relevancy score (only if sorting by relevance was used in quiery).
%rescount%
- total number of found files.
%next_results%
- links to next pages with results (printed in blocks by 20 pages).
%prev_page%
- link to the previous page with results (or empty string, if current page is first).
%next_page%
- link to the next page with results (or empty string, if current page is last).
%prev_pages%
- link to the previous block of pages with results (or empty string, if current block is first).
%next_pages%
- link to the next block of pages with results (or empty string, if current block is last).
%res_num%
- number of results in one page.
%zones_names%
- list of sections names where search was performed.
%zones_str%
- list of sections from query (string like "&z;=1&z;=3").
%ndquery%
- nondecoded query string.
%sorting%
- sorting type (takes values "R", "D", "S" and "N").
%stype%
- search type ("AND" or "OR").
%rand_number%
- random number in range from 0 to 255, which may be used in code for
banner exchange systems (the number is fixed in one section, but new number
is generated for each section).
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.
|