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

Re: Search only this category: pre-mod

Quote Reply
Re: Search only this category: pre-mod In reply to
Pugdog & Alex,

Thanks for your help so far, you've given me some good advice and after reading what you'd said I've now revamped it some more. Hopefully its more in-line with what you've suggested and so far its going well, but I've still got a problem where the search results are not restircted to the category IDs in the list.

Here's the latest version:

search.cgi

# Set catid
$catid = $in->param('catid'); # Blank if not selected from the category page

# Check catgeory ID's for 'only this cat type search'

if ($catid eq ""){$cat_name=""} else {

# Get Category Name

$cat_name = &get_category_name ($catid); # now uses routine already in DB_Utils.pm

# Get a list of category IDs where the name starts with $cat_name

$sub_list = &get_category_id_list ($cat_name); # uses new routine in DB_Utils.pm to get list of IDs
$in->param ( name => 'CategoryID' , value => $sub_list );
}

DB_Utils.pm
New sub to get comma separated list of matching category IDs (hacked from sub get_category_list):

sub get_category_id_list {
# --------------------------------------------------------
# Get a list of category IDs based on match with start of category name.
#
my $value = shift;
my ($query, $sth, $id, $name, $output, $time);

$output = $CATEGORY_LIST{$value};
$time = time();

if (!$output) {
if (! $CATDB) {
$CATDB = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Category.def";
}
$query = qq!
SELECT ID, Name
FROM Category
WHERE Name LIKE '$value%'
ORDER BY Name
!;
$sth = $CATDB->prepare ($query);
$sth->execute() or die "Can't Execute: $DBI::errstr";
while (($id) = $sth->fetchrow_array) {
($output .= "$id, ");
}
$sth->finish;
$CATEGORY_LIST{$value} = $output;
}
return $output;
}

I've also made the changes Alex suggested to Search.pm to add the CategoryID filter.

I've printed the values for $cat_name and $sub_list to the search results screen and they display OK, but the search routine still doesn't restrict found cats/links to those in the category IDs list.

Any help you could offer on the last part would be appreciated.

Thanks again, you guys Smile

All the best
Shaun

Subject Author Views Date
Thread Search only this category: pre-mod qango 11468 Sep 16, 2000, 5:09 AM
Thread Re: Search only this category: pre-mod
Stealth 11252 Sep 16, 2000, 9:08 AM
Thread Re: Search only this category: pre-mod
qango 11270 Sep 16, 2000, 11:22 AM
Thread Re: Search only this category: pre-mod
Stealth 11309 Sep 16, 2000, 11:26 AM
Thread Re: Search only this category: pre-mod
qango 11294 Sep 16, 2000, 12:02 PM
Thread Re: Search only this category: pre-mod
Stealth 11274 Sep 16, 2000, 12:15 PM
Thread Re: Search only this category: pre-mod
qango 11277 Sep 16, 2000, 12:53 PM
Post Re: Search only this category: pre-mod
Alex404 11245 Sep 17, 2000, 6:02 AM
Thread Re: Search only this category: pre-mod
Alex404 11287 Sep 17, 2000, 6:05 AM
Thread Re: Search only this category: pre-mod
qango 11271 Sep 18, 2000, 4:43 AM
Thread Re: Search only this category: pre-mod
qango 11235 Sep 18, 2000, 5:22 AM
Thread Re: Search only this category: pre-mod
Alex404 11242 Sep 18, 2000, 5:39 AM
Thread Re: Search only this category: pre-mod
Alex404 11234 Sep 18, 2000, 5:45 AM
Thread Re: Search only this category: pre-mod
qango 11244 Sep 18, 2000, 5:59 AM
Thread Re: Search only this category: pre-mod
Alex404 11228 Sep 18, 2000, 6:34 AM
Thread Re: Search only this category: pre-mod
qango 11227 Sep 18, 2000, 7:02 AM
Thread Re: Search only this category: pre-mod
Alex404 11239 Sep 18, 2000, 7:34 AM
Thread Re: Search only this category: pre-mod
qango 11223 Sep 18, 2000, 7:59 AM
Thread Re: Search only this category: pre-mod
Alex404 11207 Sep 18, 2000, 8:11 AM
Post Re: Search only this category: pre-mod
qango 11216 Sep 18, 2000, 8:16 AM
Thread Re: Search only this category: pre-mod
Alex404 11221 Sep 18, 2000, 8:29 AM
Thread Re: Search only this category: pre-mod
qango 2275 Sep 18, 2000, 8:48 AM
Post Re: Search only this category: pre-mod
qango 2240 Sep 18, 2000, 2:55 PM
Post Re: Search only this category: pre-mod
Alex404 11184 Sep 18, 2000, 8:02 AM
Thread Re: Search only this category: pre-mod
pugdog 11271 Sep 16, 2000, 2:23 PM
Thread Re: Search only this category: pre-mod
qango 11236 Sep 16, 2000, 3:14 PM
Post Re: Search only this category: pre-mod
pugdog 11244 Sep 16, 2000, 8:53 PM