Gossamer Forum
Home : Products : Links 2.0 : Customization :

Search only in categories

Quote Reply
Search only in categories
Hi Eliot, maybe it's ask before but I couldn't find it. I've copied this script from the forum:

All you need to do is in search.cgi find the following:

--------------------------------------------------------------------
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$link_results{$values[$db_category]}}, @values);
$numhits++; # We have a match!
}
--------------------------------------------------------------------

and replace it with this:

##########################################################################################
# <-------- Start subcategories search - Jose Reffoios - jreffoios@hotmail.com --------> #
##########################################################################################

# Split Categories and sub Categories into two different variables
($subcat1,$subcat2) = split(/\//, $values[$db_category]);

# do the same for the form's hidden value (category or subcateg name)
($subcat3,$subcat4) = split(/\//, $in{'thiscat'});

# check what type of category is and define what the search criteria will be
if ($subcat4) {$subcat1 = $values[$db_category];}

if ($in{'thiscat'})
{
if ($subcat1 eq $in{'thiscat'})
{
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$link_results{$values[$db_category]}}, @values);
$numhits++; # We have a match!
}
}
}

else
{
# If we have a hit, add it in!
if (($or_match && $match) or $andmatch) {
push (@{$link_results{$values[$db_category]}}, @values);
$numhits++; # We have a match!
}
}

##########################################################################################
# <--------- End subcategories search - Jose Reffoios - jreffoios@hotmail.com ---------> #
##########################################################################################

Now you just need to add, where ever you use the search
form the following (should be the "category.html" template):

--------------------------------------------------------------------
<input type="checkbox" name="thiscat" value="<Êtegory_name%>">
<font face="verdana" size="2">Search this Category</font>
--------------------------------------------------------------------


but it's not working correctly. I will explain the error in an example.
I've 3 categories: shareware - freeware - cardware
The link I'm searching for is in the category "cardware".

So when I search "only" in the category shareware (the script can't find the link = good)
When I search "only" in the category cardware (the script found the link = also good)
but when I search in both categories "shareware" AND "cardware" (the script says = link not found = is NOT good, because...)

I've tried to modify it but I can't get it to work. Can you help me with this one....

Quote Reply
Re: Search only in categories In reply to
Use Widgetz's Category Search Mod, which should be located here:

http://www.widgetz.com/links_mods/

Regards,

Eliot Lee
Quote Reply
Re: Search only in categories In reply to
Okay I will and try - thanks again Eliot

Quote Reply
Re: Search only in categories In reply to
You're welcome.

Regards,

Eliot Lee
Quote Reply
Re: Search only in categories In reply to
Hi Eiot, I tried the script but thats not what I wants.
See this link: http://search.microsoft.com/benelux/nl/SearchMS.asp

this link is what I mean in my first posting and I want to put something like that in search.html

Quote Reply
Re: Search only in categories In reply to
Uh....you can add the following codes in your search form:

Code:

<select name="category" size="1">
<option value="Freeware">Freeware</option>
<option value="Shareware">Shareware</option>
<option value="Get a Perl Book">Get a Perl Book</option>
</select>


with WIDGETZ MOD....IT WILL WORK!!!!! Tongue!!!

BTW: I would greatly appreciate it if you WOULD stop addressing me directly in your Threads...I am not the only one around here who can help you. Wink

Thank you.

Regards,

Eliot Lee
Quote Reply
Re: Search only in categories In reply to
Hi Eliot, i've put these code into my search.html:

<input type="checkbox" name="thiscat" value="<%shareware%>">Shareware <input type="checkbox" name="thiscat" value="<Êrdware%>">Cardware <input type="checkbox" name="thiscat" value="<%freeware%>">Freeware

but then I get an error as explained in the first posting...
and with this code I can search only in 1 category
<select name="category" size="1"><option value="Freeware">Freeware</option><option value="Shareware">Shareware</option><option value="I've got a Perl Book">I've got a Perl Book</option></select>


BTW: I would greatly appreciate it if you WOULD stop addressing me directly in your Threads...I am not the only one around here who can help you

I know but you are the BEST!!!!


Quote Reply
Re: Search only in categories In reply to
Oh..so, you want to search multiple categories at the same time...that would be more tricky and the codes you posted before in your first Post should go in your sub search...I betcah you have the codes in the sub main routine.

In Reply To:
I know but you are the BEST!!!!
Really, I am NOT the BEST and there are many other LINK users who are capable and willing to help!

Regards,


Eliot Lee
Quote Reply
Re: Search only in categories In reply to
I betcah you have the codes in the sub main routine.
You lost... it's in the right sub...
I think it's missing a code not to look only in 1 category but into more... See my example in the first posting...



Quote Reply
Re: Search only in categories In reply to
Which "right" sub-routine??? Wink

It should be in the sub search routine.

In Reply To:
I think it's missing a code not to look only in 1 category but into more... See my example in the first posting...
If I have time...may be.

Wink

Regards,


Eliot Lee
Quote Reply
Re: Search only in categories In reply to
Hacktor

Dunno about checkboxes cuz I haven't used them yet, but why not try dropdown select boxes instead?

I use a combination of widgetz' code mentioned by AnthroRules above and jeffo's solution for searching subcats and altcats, and it provides correct results every time.

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

http://www.gossamer-threads.com/...amp;page=0&view=

HTH Smile

Quote Reply
Re: Search only in categories In reply to
also thanks for responding. I will try to explain it. If you visit this link: http://search.microsoft.com/benelux/nl/SearchMS.asp then you know what I mean. A visitor can deside where to search in. I've also a script (download free: http://awsd.com/scripts/) to search for keywords in website. So the search option in my website must be a combination, -to search in the links database and search for keywords on my site... Thats way I'm looking for this MOD or modification of the script above. I hope someone can help me with this...

Quote Reply
Re: Search only in categories In reply to
Here are some suggestions:

1) Copy the other search script into your LINK's search.cgi.

2) Then use the Search Redirection Mod found at:

http://lookhard.hypermart.net/links-mods/

to set-up the option to search either database.

3) Then use the Altavista Mod for printing both results from each of the databases in your main search results page.

Regards,

Eliot Lee
Quote Reply
Re: Search only in categories In reply to
Thanks, thanks again Eliot...

Quote Reply
Re: Search only in categories In reply to
You're welcome...and if you notice I've suggested you do this TWICE now.

Wink

Regards,

Eliot Lee