Gossamer Forum
Home : Products : Links 2.0 : Customization :

Cat. Search with Alt Cat

Quote Reply
Cat. Search with Alt Cat
I'm using Widgetz's Category Search mod at http://www.widgetz.com/...earch-templates.html

And would like the code to also look at the alt-categories. Can someone tell me what to change in the code?

Code:
if ($in{'category'} && $in{'category'} ne "All") {
($values[$db_category] =~ /^$in{'category'}/) or next LINE;
}


Thank You
Shane
Quote Reply
Re: Cat. Search with Alt Cat In reply to
Do you think I can have some help with this Widgetz?

Thanks
Quote Reply
Re: Cat. Search with Alt Cat In reply to
Go to the following Thread:

http://www.gossamer-threads.com/...um3/HTML/003409.html

Download the search.cgi file. You will see codes in it for searching Altcategories.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Cat. Search with Alt Cat In reply to
Thanks for the help Elliot.

I stuck this in search.cgi
Code:
if (defined $db_alt) {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
next unless ($_ =~ /^$in{'category'}/);
$found = 1 and last;
}
}
($values[$db_category] =~ /^$in{'category'}/) and $found = 1;
($found) or next LINE;

}

But it didn't work. Is this the right code?

Here's my script:
www.marketuplinks.com/search.txt

This is my search page www.marketuplinks.com/search.htm and wall street journal should appear in the forex category.


Thanks
Shane
Quote Reply
Re: Cat. Search with Alt Cat In reply to
Make sure that you have defined $db_alt in your links.cfg file.

Also try changing @alt_categories to @altcategories.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Cat. Search with Alt Cat In reply to
the proper code is

Code:
if ($in{'category'} && $in{'category'} ne "All") {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
next unless ($_ =~ /^$in{'category'}/);
$found = 1 and last;
}
($values[$db_category] =~ /^$in{'category'}/) and $found = 1;
($found) or next LINE;
}

------------------
Jerry Su
Links SQL Licensed
------------------
Quote Reply
Re: Cat. Search with Alt Cat In reply to
keep in mind.. if you search for something in a category.. say "Toys" and the ALT is also in "Toys/Plastic" then the link will show up twice.. that is why i didn't use it..

------------------
Jerry Su
Links SQL Licensed
------------------
Quote Reply
Re: Cat. Search with Alt Cat In reply to
I changed to @altcategories but no luck.

Was I supposed to add:
$db_alt = "$db_script_path/data/links.db";

to links.cfg? That didn't work either.
Quote Reply
Re: Cat. Search with Alt Cat In reply to
NO...You have to define $db_alt in the Important Fields Area in the links.def file...Sorry, I told you the wrong file.

It should be something like:

Code:
$db_alt = 15;

15 being the field number of the AltCategories.

Best of luck,

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: Cat. Search with Alt Cat In reply to
O.K, I added:

$db_alt = 5;
to links.def pointing to the alt category

Used this code; added a } bracket because it gave me errors, hope it's right

Code:
# Search ALT categories
if ($in{'category'} && $in{'category'} ne "All") {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
next unless ($_ =~ /^$in{'category'}/);
$found = 1 and last;
}
}
($values[$db_category] =~ /^$in{'category'}/) and $found = 1;
($found) or next LINE;
}


tried @altcategories and @alt_categories and even added the alt categories to
@search_fields = (1,2,4,5,6,7,8,19,21);


And it's not working Smile
Any other clues you guys can offer me?


Shane
Quote Reply
Re: Cat. Search with Alt Cat In reply to
you have an extra bracket.. but i'd think the search would return a 500..

------------------
Jerry Su
Links SQL Licensed
------------------
Quote Reply
Re: Cat. Search with Alt Cat In reply to
I was missing a bracket before the code and fixed it but now with Widget's code it searches through all the categories even when only one is selected. Seems to disregard the category all together.
Quote Reply
Re: Cat. Search with Alt Cat In reply to
widgetz ...

in

if ($in{'category'} && $in{'category'} ne "All") {

add

my $found = 0;
Quote Reply
Re: Cat. Search with Alt Cat In reply to
I'm having the same prob as shane1800. AltCategories are not showing up in the search results.

I'd like to try xiaoying's idea. Where should I plug in:

my $found = 0;

Should it look like this:

######### Begin widgetz search category mod part 1/1 ################
if ($in{'category'} && $in{'category'} ne "All") {
($values[$db_category] =~ /^$in{'category'}/) or next LINE;
my $found = 0; # xiaoying
#######################################################################
### ( WORK WITH ALTCATEGORIES AND ADD GO ON WITH EACH IF MATCH ) ###
#######################################################################
if (defined $db_alt) {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
next unless ($_ =~ /^$in{'category'}/);
$found = 1 and last;
}
}
($values[$db_category] =~ /^$in{'category'}/) and $found = 1;
($found) or next LINE;
#######################################################################
}
######### End widgetz search category mod part 1/1 ####################


Many Thanks Smile
Quote Reply
Re: Cat. Search with Alt Cat In reply to
Here's Jeffo's solution. Works for me...thanks for everyone's help Smile

http://www.gossamer-threads.com/...ew=&sb=&vc=1

#JefMod added search in category plus subs AND NOW ALT
if ($in{'category'} && $in{'category'} ne "All") {
($values[$db_category] =~ /^$in{'category'}/) || ($values[$db_alt] =~ /$in{'category'}/) or next LINE;
}
#JefMod end