Gossamer Forum
Home : Products : Links 2.0 : Customization :

Similar Search Terms mod released...

Quote Reply
Similar Search Terms mod released...
A quick post of a simplified version of a mod I did a while back. It's available on my site now.

An example is say you searched for 'music' a list of similar search terms are displayed:

Now search for pop music
Now search for rock
etc..........

(These next two weeks I will be very busy and so won't be able to give much support)
However it's quite simple so shouldn't really cause to many problems.



Good Luck!

Glenn
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: [glennu] Similar Search Terms mod released... In reply to
I followed Glenn's instructions exactly, however, when I visit my search page it comes back with an 500 server error. All permissions have been applied correctly and uploaded in ASCI mode, has anyone had success with installing this mod?

============================================
http://cgi-resource.co.uk/pages/ssearch.shtml

Open search.cgi

At the bottom of the first sub just above:

# Print out the HTML results. 
    &site_html_search_results;          
 

Add:
 

$ccount=0;
open (DB, "<similarsearch.db") or &cgierr("error in search. unable to open database: $db_file_name. Reason: $!");
    flock (DB, 1) if ($db_use_flock);
    LINE: while (<DB>) {
        /^#/      and next LINE;        # Skip comment Lines.
        /^\s*$/   and next LINE;        # Skip blank lines.
        chomp;                          # Remove trailing new line.
        @values = &split_decode($_);  

foreach $term (@search_terms) {
  $_ = $values[2];
  if ((m/$term/i) and ($ccount < 5)){
     $ssearch_results .= qq|Now search for: <a href = "search.cgi?query=$values[1]">$values[1]</a><br>\n|;
     $ccount++;    
  }  


close DB;
 

Where similarsearch.db is the path to your db file
$ccount < 5 is the max number of similar terms you want displayed
 

Then go into site_html_templates.pl and add the following in the search results sub:

ssearch_results => $ssearch_results,

Then in search_results.html add:

<%ssearch_results%>
 
Then make the similarsearch.db:

Here's an example of what to use:
The first fields if the id number, the second the similar search term and the third is an array of words you want to pick up the search term.
 

1|pop| music rock indie

So for instance above if you search using a word such as music, rock or indie in your search 'now search for pop music' will be displayed.

http://cgi-resource.co.uk/pages/ssearch.shtml


Pickle Network
Network of websites both salty and dill.

Last edited by:

asmith: Apr 20, 2004, 12:37 PM
Quote Reply
Re: [asmith] Similar Search Terms mod released... In reply to
I have not used this mod, but have a suggestion... Did you set this line?

$ccount=0;
open (DB, "<similarsearch.db")

Per the instructions, it should be written as the path to the file:

/admin/data/similarsearch.db

or similar. Also you need to create the db file.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Similar Search Terms mod released... In reply to
Hey Flunkie,

Yeah I have tried that, still doesnt work. I have tried the following as well...

open (DB, "</admin/data/similarsearch.db")
open (DB, "/admin/data/similarsearch.db")
open (DB, "$db_script_path/data/similarsearch.db")

No luck.

- Andy


Pickle Network
Network of websites both salty and dill.
Quote Reply
Re: [asmith] Similar Search Terms mod released... In reply to
Well, did you make the change in site_html_templates.pl?


sub site_html_search_form {
# --------------------------------------------------------
# This routine displays the search form.
&html_print_headers;
print &load_template ('search.html', {
term => $term,
error => $error,
ssearch_results => $ssearch_results,
%in,
%globals
});
}

Other than that, can you check cgi error logs on your server?


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Similar Search Terms mod released... In reply to
Flunkie,

No I missed that, I just now added it but didn't seem to help. I have checked out my error logs and didn't see anything related to the search file. Thanks a lot for your feedback I really appreciate it.

I am going to reinstall the mod (reconfigure from scratch) and see if that helps. If it doesn't work I'll just move one, thanks again!

Best.

- Andy


Pickle Network
Network of websites both salty and dill.