docs.roxen.comBack to normal mode
DocsRoxenWebServer 5.1Web Developer ManualSearch
Copyright © 2013, Roxen Internet Software
Suggestions, comments & compliments


The RXML Interface consists of a set of tags that are used to input queries from the user and present the results of running the queries. The absolute minimum you have to write to get a search page with a search form and a results listing is:

<html><body> <search-form/> <search-results/> </body></html>

You can also have the search form and the result listing on different pages:


<html><body> <search-form action="results.html"/> </body></html>


<html><body> <search-results/> </body></html>

The search form and the results listing communicate via form variables. However you can override various aspects of their behaviour. E.g. you can write a results listing for a hard-coded query:

<search-results query="fruit"/>

Customized Forms

To create a customized form, use <search-form> as a container. Since it will generate a <form> container in the output, you can use all <input> and <select> elements that you would use in any <form>. You can add attributes to the resulting <form> by adding them to <search-form>, e.g. change the method="GET" (which is the default), to method="POST".

Example (in French):

<search-form method="POST" action="results.html"> Tapez quelques mots descriptifs et cliquez sur le bouton:<br /> Requête: <input type="text" name="query" /> <br clear="all" /> <input type="submit" value=" Recherce " name="submit" /><br /> </search-form>

For convenience, there are two subtags that you can use inside <search-form>:


generates RXML to get the database profile to search in, and puts the name of it in the form variable 'db'.


generates RXML to get the type of search to do, either "or" or "and", and puts it in the form variable 'type'.

Since the default RXML code for <search-form> and <search-results/> communicate via form variables, you have to make sure that if you alter either one of them, the other checks for the right variables. If you put this inside <search-form>:

Enter your query: <input type="text" name="q"/>
then you will have to see to it that <search-results> uses the variable 'q', and not 'query':

<search-results query='&form.q;'/>

Customized Results

The tag <search-results> is used to generate multipage search result listings. As seen above it can be used as a single tag, thereby using the default RXML content.

The search results listing can also be customized and given different layouts. There are two subtags to <search-results>, namely <search-results-entries/>, and <search-results-tabs/>.

<search-results-entries/> generates a listing of hits, but only the hits on the current page. When used as a single tag, a default piece of RXML code is inserted.

<search-results-tabs/> generates a tab list with links to other pages with hits. When used as a single tag, a default piece of RXML code is inserted.

Inside <search-results> there are entities available about the results of the search. For example, you can create a result page that does not show links to the matching documents, but rather just some info about the search:

<search-results> <if expr="&_.hits; == 0"> Sorry, but your query: '&_.query;' did not match any documents!<br /> </if> <else> You were looking documents matching '&_.query;' in the database '&_.db;'.<br /> &_.hits; matching documents were found.<br /> The search took about &_.time; seconds.<br /> </else> </search-results>

But then you would want to present the matching documents too. That is done with the <search-results-entries> container. It loops through the documents on the current listing page, in order. How many documents it will loop through can be controlled by setting the perpage attribute of the surrounding <search-results> container, or if that attribute is missing, the default setting in the SiteBuilder Interface is used. A good value is probably somewhere between 10 and 20.

What document will start with depends on what page is focused. That is controlled by the page="" attribute to the surrounding <search-results> container, or if that is missing, by the form variable 'page'.

For each document, the <search-results-entries> container runs through its content, setting the entities to different values before each loop to reflect the properties of the current document. There are more than ten different entities so refer to the documentation for the tag for all of them. An easy example using the most useful of them:

<search-results-entries> <h2>&_.title;</h2> <p><i>&_.description;</i><br /> <font size="-2">&_.body:none;</font><br /> Size: &_.nice-size; Score: &_.score;<br /> <a href="&_.uri;">&_.nice-uri;</a> <if variable="_.content-type == application/pdf"> [PDF file] </if> </p> </search-results-entries>

The tag <search-results-tabs/> works similarly. But instead of looping through the documents on the current page, it loops through all pages in the listing. For each page it gives information about on which document it starts and ends, what page number it has and so on. This tag is used to make a list of links to the other pages. It can be used as a container if you want to make your own layout of the links.

In each link, make sure to pass, along with the page number, all variables that are needed to identify the search, namely:

&_.query;, &_.query-profile;, &_.db;, and &_.type;