Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Excluding Categories from search

Quote Reply
Excluding Categories from search
Hi there,

I'm trying to exclude categories from the search, but I just can't get it. I have search through the forums, but couldn't find any useful information regarding this. I understand that this will most likely have to be a change in the "search.pm"., but I just couldn't find the right method to do it. I think it's more likely that the code did work, but the server took some time show the changes. I'll try to find a way on a local instance of GLinks next week, but in the mean time, if anyone can help me, please do.

Thanks ^_^


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Excluding Categories from search In reply to
Hi,

I've tried doing this before too, but to no avail. It must be possible - but the search function is very complex - and its hard to know exactly what going on where (and what to edt)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Excluding Categories from search In reply to
Another thing is, I have been able to figure out that by sending two or more category id's along with the rest of the variables frm the html form, only those categories specified would be searched in. So by sending all the category id's ,excluding the ones you don't want to search, it will work. This I have tested. To send them like that you will need to add a bunch of hidden inputs, like this:

Code:
<input type="hidden" name="catid" value="12" />
<input type="hidden" name="catid" value="23" />
<input type="hidden" name="catid" value="2" />
<input type="hidden" name="catid" value="3" />
<input type="hidden" name="catid" value="6" />

This will have the search script only search those categories and their sub-categories, which is want I want to do, becuase these inputs can be generated with a global. Unfortunately it doesn't really help me with my situation.

I want the user to be able to choose wether he wants to search in a single category, or the whole database. But there are categories that I don't want them to search. By putting all of this on one form, using the above method, the option of the user searchng in one category will be rendered useless, as the hidden inputs will be sent along anyway...


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Excluding Categories from search In reply to
We had a similar problem on our site and we got around it by adding a custom field to the Links table, called 'Type'. In our case we have several types, but this should work for you.

If you have links in categories you don't want included in searches, you set the Type value to whatever you like e.g. 'Hidden'.

Then it's just a case of adding a hidden field to the form code:

Code:
<input type="hidden" name="Type" value="Searchable" />

and only the links with Type=Searchable will be shown. It won't stop people manually editing the URL and removing the 'Type' restriction but that doesn't concern us a great deal.

It would be easy enough to generate an SQL statement to set the Type value in your existing Links table based on the category, then for future validated links you set the value manually (make the default yes or no as appropriate).

A dodgy system perhaps but it works for us!