Sphider: The Web Site Search Tool
One of the first things that any visitors considers doing when they hit your web site is to search. This is all and well if you are running an PHP/MySQL driven web app like OScommerce or Expression Engine, but what if your site runs on static pages like this one? You can’t always rely on Google to supply the best results with their in-page site search form, because it takes time for the Google search index to update, despite using all the means available to nudge and push them. So what alternatives are there?
In this article we take a quick look at implementing Sphider, a PHP/MySQL based solution that can be used to provided weighted results, and could even be used to clear up your web site pages metadata!
Getting Your Search Started
Once you have the code downloaded form the Sphider search website, upload it to your website and unpack it.
The subsequent process of getting setup, isn’t exactly seemless but then again, it isn’t exactly impossible either. One thing’s for sure, Sphider, though effective, could certainly do with some polishing:
Step One - is to create a database and appropriate user, and to apply the necessary access and privs for that user. Once you have done this, simply edit the “settings/database.php” file with the correct data.
Step Two - is to load up the web-based install script “http://domain.com/sphider/admin/install.php” which initialises the required tables in the database. After this is done I would recommend deleting any remnants of the install script from the server to avoid it being re-used later, by you or anyone else.
Step Three - is to login to the admin panel: “http://www.domain.com/sphider/admin/” (the defaults are admin and admin) and create a “Site”. With the site setup, click the “options” link to reveal the info and then click the “index” link; this will force run a spidering of the site and generate the required data in your database.
Minor Name Adjustments
Once step one, two and three are completed, you are pretty much ready to go, other than just linking up the search box or search page to all the desired pages on the existing web site. That being said, I made a couple of important changes. Rather than keep search in a directory called “sphider” I switched this to “search” and rather than produce a directory index of that folder on the site, I changed the “search.php” filename to “index.php”. Having done so, you have to change any “search.php” references in the “themes/default/” folder to “index.php” also.
Changing the Look and Feel
Creating yoru own look and feel is also easy. To get started ake a copy of the “theme/default/” folder and open up the files in your favoured editor. The filenames pretty much say what they do on the tin. To create a design wrapper simply paste the appropriate code into the “header.html” and “footer.html” files.
Adding a site-wide search box can be done with the basic form html that includes a hidden input with a name of “search” and a value of “1″ and a text entry field named “query”, then just put it at your search script which by default would be “/sphider/search.php”.
The rest of the beautification process should be accomplished in CSS using the theme “search.css” file. If you need ideas on how to format and place the respective details of the search results I would suggest looking to the most popular search engine on the planet, as it is best to follow conventions when it comes to usability.
Conclusion: Quick and Easy
The real upside for Sphider is that you can get up and running relatively quickly, having overcome its installation foibles. And that having done this once, you will then be able to implement search on every site you have in just a few minutes each. The search results are good, and the system effective, you can’t fault that, but from a coder’s perspective there are some definite improvements to be had.
As I hinted initially, once you have Sphider installed and you see the available results formatting, you may just want to start looking again at all the titles and meta descriptions of every page on your site.
For further tweaking you will most likely want to read the documentation, but to kick things off, head on over to the Sphider Search website.