Table of Contents
Build a search page using the PHP language.
A working install of focuseek searchbox
A working install of a web server with PHP page handling enabled
Interfacing with searchbox requires the PEAR SOAP PHP extension.
To verify which extensions you have already installed, open a shell and
type pear list (you may need to execute this and the
following commands as root). If the package SOAP is
installed, proceed to the next step.
The SOAP extension is currently marked as beta, so the first thing
you have to do is change the preferred_state PEAR
configuration variable to the beta value: type
pear config-set preferred_state beta.
Now you are ready to install the SOAP package: type pear install -a SOAP. PEAR will download and install the SOAP package and all dependent packages. During this stage, PEAR may complain about installed packages that are too old: in this case you will have to upgrade these packages by typing pear upgrade PackageName
If all went OK, PEAR will inform you that the SOAP package has
been successfully installed. You can switch back to the
stable value for the
preferred_state PEAR configuration variable by typing
pear config-set preferred_state stable. Now you are
ready to proceed to the next pass.
You need to use the GUI to create a source and the corresponding archive that will hold the content you want to make searchable. See the GUI manual to learn how to do it.
After creating the archive, jot down its ID because we will need it in the next step. You may want to start the crawl in order to have some documents indexed to query later on.
You aren't really going to create anything here, because we have
done the hard work for you! Grab the search.php
file from the examples/cookbook/php-search-page
directory of your searchbox installation and put it in a suitable place
into your web server document directory.
You may want to change the $soapclient variable
definition to adjust the username, password, hostname and port of your
searchbox installation, and the $archives variable
definition to change the 1 to the ID of the archive
you have set up in the previous step.
Open your browser, and type the URL relative to the
query.php page. A text field and a button should
appear in your browser. Type in one or more keywords in the text field
and press the button: search results should be displayed in the
browser.
This simple search page lacks support for results pagination: you
will be able to see only the first 10 results. You can implement
pagination by using the FirstDoc and
LastDoc query parameters. We leave the implementation
to you as an exercise.