Gossamer Forum
Home : Products : Links 2.0 : Customization :

alt categories mod and search subcategories mod

Quote Reply
alt categories mod and search subcategories mod
Hi,

I've tried to use these two together and it's not quite working.

The problem is that the search subcategories doesn't look in the AltCategories field. But if you just add it to the search like "&AltCategories=CatName" it looks for a record with both the catgory= defined and the AltCategories defined.

I've tried to say something like:
If no match in category - then turn around and search in altcategory. Or if record has AltCategory then $category=Name|AltName using the pipe as an alternative.

But anyway - I'm not doing it right. The search works somewhat but I get duplicates of some records.

Has anyone else got a workaround for using these two mods together?

Thanks.

Quote Reply
Re: alt categories mod and search subcategories mod In reply to
Widgetz wrote a code hack for the Altcategories search awhile back...and the codes have been re-posted in the following Thread:

http://www.gossamer-threads.com/...w=collapsed&sb=5

by DogTags.

Although these codes do not work very well either.

Regards,

Eliot Lee
Quote Reply
Re: alt categories mod and search subcategories mod In reply to
Well thanks for the help but it didn't work for me.

I did however come up with a solution that seems to work like a charm.

It's so SIMPLE I can't believe I didn't see it earlier.

I just modified the code used to do the subcat search as follows:

In Reply To:
#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
I can't find anything wrong with this code and it allows for the subcategory search as well as alt categories coming up in the search results even if they're "subcategories" that are alt-categories.

Hmmm. I'm encouraged.

Hope you guys can use this! :-)

Thanks for the help anyway.

Quote Reply
Re: alt categories mod and search subcategories mod In reply to
Hey jeffo

I am happy to report that so far I'm getting good results with your code.

I was particularly concerned about doing searches within specific altcategories when the main category might be the only info that the search could grab.

For instance, let's say that I have Supplier X listed in Category Aviation_Surplus, State North Carolina, and AltCategories Boating. Plus, let's also say that the descrip is kind of weak and doesn't have anything in it for boating. Using your code, if I searched for "boat", All States, All Site, Supplier X was returned. If I searched for "boat", North Carolina, All Site, Supplier X was returned. Then, "boat", Delaware, All Site, Supplier X was not returned - which is a correct outcome. Etc...

All the results were correct on any combination of search-enabled fields.

It looks like you nailed it.

Yeah!Cool

Quote Reply
Re: alt categories mod and search subcategories mod In reply to
Code:
Well thanks for the help but it didn't work for me.
I didn't say that I gauranteed it would work...all I did was provided a suggestion.

Best of luck with your LINKS project!

Regards,

Eliot Lee
Quote Reply
Re: [jeffo] alt categories mod and search subcategories mod In reply to
Did you insert this code into search.cgi? If so, where at?

This is exactly what I am looking for but am not sure what file to insert this code into.

Thanks

James
Quote Reply
Re: [justjames] alt categories mod and search subcategories mod In reply to
Read the thread that is linked from this one, it tells where the code is changed; yes, in search.cgi:



In search.cgi
########## BEGIN CATEGORY SEARCH ###################
if ($in{'category'} && $in{'category'} ne "All") {
($values[$db_category] =~ /^$in{'category'}/) or next LINE;
}
############ END CATEGORY SEARCH ######################
############ BEGIN STATE FIELD SEARCH ################
if ($in{'state'} && $in{'state'} ne "All") {
($values[$db_state] =~ /^$in{'state'}/) or next LINE;
}
########### END STATE FIELD SEARCH ##################


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] alt categories mod and search subcategories mod In reply to
Hi Leonard,

I must be totally lost. I made some modifications but it didn't show any changes as to showing the alt categories on my searches.

Is there anyway there can be a post that shows what to modify on different files? Is search.cgi the only file that is modified to show alt category listings?

An " A B C " for this mod would be great here. I have seen the other threads but they are in pieces. Plus the thread referenced worked on "states" as an alt category. Mine is more in general.

Clarification would be great. Thanks so much.

James