Gossamer Forum
Home : Products : Links 2.0 : Customization :

Re: How do you make category KEYWORDS searchable?

Quote Reply
Re: How do you make category KEYWORDS searchable? In reply to
the field names are only used with hashes..

the only problem here is:

Code:
# Go through the database.
open (DB, "<$db_category_name") or &cgierr("error in search. unable to open database: $db_category_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($_);
$grand_total++;
# Check to see if the category matches.
$match = 0; $andmatch = 1;
if ($regexp) {
FIELD: foreach $field (@searchcat_fields) {
$_ = $values[$field];
$or_match ?
($match = $match | | &{$regexp}) :
($match = &{$regexp});
last FIELD if ($match);
}
}
# Check to see if the category matches any database fields. Only exact matches
# here.
if ($or_match | | $match | | !$regexp) {
FIELD: foreach $field (@field_search) {
if ($or_match) {
$match = $match | | ($in{$db_cols[$field]} eq $values[$field]);
$match and last FIELD;
}
else {
$match = ($in{$db_cols[$field]} eq $values[$field]);
$match or last FIELD;
}
}
}
$andmatch = $andmatch && $match;
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$category_results{$values[$db_category]}}, @values);
$numhits++; # We have a match!
}

and then there are alot more.. you can't put it inside the other openin DB thing either..

to do it.. it's pretty easy.. the code you show here is on the right track.. but will lead to a dozen or more errors..

if i were you i would put something like this above where it opens the links.db..

Code:
@searchcat_fields = ();

# Go through the database.
open (DB, "<$db_category_name") or &cgierr("error in search. unable to open database: $db_category_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($_);
$grand_total++;
# Check to see if the category matches.
$match = 0; $andmatch = 1;
if ($regexp) {
FIELD: foreach $field (@searchcat_fields) {
$_ = $values[$field];
$or_match ?
($match = $match | | &{$regexp}) :
($match = &{$regexp});
last FIELD if ($match);
}
}
# Check to see if the category matches any database fields. Only exact matches
# here.
if ($or_match | | $match | | !$regexp) {
FIELD: foreach $field (@field_search) {
if ($or_match) {
$match = $match | | ($in{$db_cols[$field]} eq $values[$field]);
$match and last FIELD;
}
else {
$match = ($in{$db_cols[$field]} eq $values[$field]);
$match or last FIELD;
}
}
}
$andmatch = $andmatch && $match;
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@category_results, $values[1]);
$numhits++; # We have a match!
}
}
close DB;

i'm not saying that will work.. but it's more of what it should look like..

jerry
Subject Author Views Date
Thread How do you make category KEYWORDS searchable? Dee 1978 Sep 5, 1999, 8:43 AM
Post Re: How do you make category KEYWORDS searchable?
Eliot 1932 Sep 4, 1999, 9:35 PM
Post Re: How do you make category KEYWORDS searchable?
Bmxer 1933 Sep 4, 1999, 9:48 PM
Post Re: How do you make category KEYWORDS searchable?
widgetz 1932 Sep 5, 1999, 5:25 PM
Post Re: How do you make category KEYWORDS searchable?
Bmxer 1932 Sep 5, 1999, 6:24 PM
Post Re: How do you make category KEYWORDS searchable?
widgetz 1934 Sep 5, 1999, 7:36 PM
Post Re: How do you make category KEYWORDS searchable?
Dee 1932 Sep 6, 1999, 2:31 PM
Post Re: How do you make category KEYWORDS searchable?
Bmxer 1932 Sep 6, 1999, 3:10 PM
Post Re: How do you make category KEYWORDS searchable?
widgetz 1933 Sep 6, 1999, 3:34 PM
Post Re: How do you make category KEYWORDS searchable?
widgetz 1932 Sep 6, 1999, 3:36 PM