Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

exclude a category from search-routine

Quote Reply
exclude a category from search-routine
Hello,
is it possible to 'exclude' a category / directory from the search-routine? So that the script ignore category "XYZ" when a user search something?

Thanx in advance...

earfi

Quote Reply
Re: exclude a category from search-routine In reply to
Yes and no.

search.cgi uses the 'query' command, which doesn't seem to allow 'and not' type parameters.

There are a couple of ways to do it, you can check the return values, and exclude links and categories that meet a criteria, or you can add a parameter to the query routine (of DBSQL.pm).

Pass in another parameter $and_stuff that contains the tail end of the Where clause... such as AND !NOT or CategoryID NOT IN ( )

and pass it to the query: and_stuff => $and_stuff

Then, in DBSQL.PM you need to check for that paramter at the top:

my $and_stuff;
($opt_r->{'and_stuff'}) ? ($and_stuff = $opt_r->{'and_stuff'}) : ($and_stuff = '');

Then, in the two queries... where they check for count, and then get hits:

$query = qq!
SELECT COUNT(*)
FROM $table
$where $and_stuff
!;


and then,


$query = qq!
SELECT *
FROM $table
$where $and_stuff
$sb
LIMIT $offset, $maxhits
!;


This is an idea, not guaranteed to work, and it may generate errors that are not trapped properly if you don't make the $and_stuff parameter a legitimate statement phrase.



PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://postcards.com/FAQ


Quote Reply
Re: exclude a category from search-routine In reply to
Hi Pugdog,

thank you for the posting...
So what i have to do, when i want to exclude the top-category "Science"(ID=100) with all its subcategories?

Thanx in advance!

Coyu