Skip Navigation

www.wimb.net - Sphider Integration


Sphider


Sphider Logo - link to Sphider website



On this page:

Integrating Sphider

This page describes how to integrate Sphider seamless into your website. To be more accurate: it describes how Sphider is integrated in this website.
The used version is: Sphider 1.3.4, release date 29-04-2008

What I want on my website:

  • Search Box at the top of each page that links to a section search page that uses the same style as the section from where the search is started.

Sphider Installation

All installation steps are perfectly described in the file install.txt that comes with Sphider. Here this file is not repeated, but I've placed some remarks with the same reference number as in install.txt

The fist thing to do is to setup the basic functioning of Sphider: uploading the files, generating the MySql tables and running the first index.

1.3 edit database.php - here I used a prefix for the Sphider tables:

$mysql_table_prefix = "zz_";

Now all the Sphider tables will be grouped together and that is very handy in case you have to delete them for a new setup. If you use a separated database for Sphider then this is not necessary.

After successful creation of the tables the following message will appear:

creating tables successfully completed

After running the install script you should have a look with phpMyAdmin to see if the tables are there and at the correct place.

If all OK, you can log in at the admin panel, add your site and start indexing.

After receiving the ready message: Completed at 14:51:32 completely at the bottom of the (very long) page. Go via the link at the top of this page to the admin page. If you like you can change the login before, but I prefer to start with the default login.

Under the "Settings" tab Sphider can be adapted to your needs. This is all written in the install.txt file and it can be found on: http://www.sphider.eu/docs.php





index-php_structure

First Sphider Search

Now Sphider is ready to do the first search. Go to "site/new_search/search.php" Where "site" is the url of the website and "new_searech" is the directory where Sphider is installed. Point 7 of the install.txt file is a bit unclear, here index.php is mentioned as the default search page, but this file does not come with the Sphider package. So here search.php is used.

When it is good, you see this on a further complete empty page:

default sphider search page

This is of course not what we want, but this is a very good place to see if Sphider works. Type a popular word to search for, like "Delphi" and this will give over 400 matches, because this word is used very often, IT WORKS !!!

Sphider Integration - Search Page

The structure of this site is described here index.php?s=site&page=0 When we look at a page, then there is a fixed layout, with in the middle a large DIV with the content.

This content is included in the main file: index.php To make an integrated Sphider search page search.php must be included in index.php This can be done direct, but I like search pages with their own section colors so I have to make in each section a search page. To make complex stuff a bit simple they in all section the search pages have the same page number = 91

To make the empty search page for the "site" section of wimb.net, I have to make a file that is called:
sitepage91.php

When http://wimb/index.php?s=site&page=91 is called, than the sitepage91.php is automatically included by index.php

sphider_empty_search_page Here is this empty page: On the left the index.php that calls sitepage91.php

What's in this file? Nothing, absolutely nothing.

sitepage91.php is an empty file. if it did not exist then the section homepage (page=0) would have been displayed.

Now we want to see the search results. A simple include does the job:


<?php
echo '<h1>Sphider Search Page</h1>';
include('new_search/mysearch.php');
?>

This is so far the whole content of the sitepage91.php file

Ready?

sphider simple search page

Is this all?, no of course not. It will not work, because the search.php is included in index.php and runs now in the root of the site. The path setup for the include files in the lines 33 to 36 has to be changed. Keep the original version, copy and rename search.php to mysearch.php

Now change the include path settings ex:

$include_dir = "./include"; becomes

$include_dir = "./new_search/include";

etc. Then with this result:

This is with the advanced search box, set with the Sphider Admin Setup. Also it does not work yet, the search form calls still search.php and that one we don't want to use anymore. We copied it to mysearch.php

Also there are still the header and footer included. These have to be removed. Put // at the begin of line 47 to remove the header and do the same at line 141 for the footer. To keep the JavaScript Framework Suggestion working that is called in the header, the script has to be moved to the header of the search page. It is about these three lines:

<style type="text/css">@import url("new_search/include/js_suggest/SuggestFramework.css");</style>
<script type="text/javascript" src="new_searxh/include/js_suggest/SuggestFramework.js"></script>
<script type="text/javascript">window.onload = initializeSuggestFramework;</script>

The path to the scripts has been changed to be called from the server root.

To get the search button working the search_form.html has to be modified. Since this form still is made with tables I copied it to the "new-search" dir and now it can be modified completely. Also the include in mysearch.php on line 89. Also it was renamed to searchform.php Change the first line of the form to: <form action="index.php?s=site&amp;page=91" method="post">

In mysearch.php I removed also the remark on line 10: extract(getHttpVars()); With this line remarked it is not working.

In some cases you can have a message: "illegal include" This comes from Sphider and can be found at line 10 of the commonfunc.php. The new path to the Sphider files must be in an array. For more information are here two links to the Sphider Forum:

Then, again, IT WORKS !!!

sphider search page with result

Is it now ready? Yes and no. The link in the "Did you mean:" script has in the search_result.html page has to be corrected. The small Sphider image is missing and many more of these small things.

The w3.org validator gives still 48 errors and I like absolute that my pages are 100% XHTML validating. The errors are in the form and in the JavaScript. This cleanup is a separate job and has nothing to do with the Integration of Sphider which is done and ready now.

Sphider Integration - Search Box

The search box at the top of each page is nothing more than a text file that is included:

site search box

And below is the code from the text file:

<!-- include text file for Sphider search  -->
<form accept-charset="UTF-8" id="sitesearch" class="flr" 
      action="index.php?s=<?php echo $secstr &amp;page=91" method="post">
<fieldset>
  <label for="sphidersearch">
     <input id="sphidersearch" type="text" name="query" size="18" 
            value="" alt="Search Input Field" />
  </label>
  <input type="submit" value="Search" />
  <input type="hidden" name="search" value="1" />
</fieldset>
</form>

The php echo of the "$secstr" makes that at each page the search goes to the search page of the same section.



PID: 7017 CLT: 0.002 LMD: 2013-Aug-17

Updated 2007 Oct. 09