Gossamer Forum
Home : Products : Links 2.0 : Customization :

A Script....

Quote Reply
A Script....
Ok, I have been trying to modify Links 2 so that I can search specific fields, such as Company Name, Post Code etc, but I have had no success.

I am now looking for a script that will do a similar job. It doesn't need to build any pages, it is really only for the search facility. I have searched HotScripts.com and cgi-resources.com with no real success, and I was wondering if any of you guys knew of a script that would be able to do what I want Smile

Thanks

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: A Script.... In reply to
Err there's already code posted in the forum to search specific fields. There's also posts about it only yesterday I think...!

Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: A Script.... In reply to
Also trying to find a search script is nothing to do with Links2 Customization.

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: A Script.... In reply to
Links already has this feature...

Line 199 reads:
Code:
# We can also search by field names.
What you need to do, though, is make it so it doesn't do only exact matches...
Modify this code:
Code:
# Check to see if the link matches any database fields. Only exact matches
# here.
if ($or_match || $match || !$regexp) {
FIELD: foreach $field (@field_search) {
if ($or_match) {
$match = $match || ($in{$db_cols[$field]} eq $values[$field]);
$match and last FIELD;
}
else {
$match = ($in{$db_cols[$field]} eq $values[$field]);
$match or last FIELD;
}
}
}
So that you split the field on white space, then loop through that to find a match.

--Drew
Free, hot camel soup for Links hackers...
http://www.camelsoup.com
Quote Reply
Re: A Script.... In reply to
Yeah, thanks for the help. I didn't realise I posted it in the 'Links 2 Customization' forum...lol...maybe I need glasses Wink I was scanning through several different pages at the time.

Anyway, thanks for the help, I'll give Links 2 another try with what I want to do Smile

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: A Script.... In reply to
Ok, I had a look at http://gossamer-threads.com/...ew=&sb=&vc=1 and saw that they were working on a mod to do what I want.

I tried the suggestions, by doing the following in links.def;

Add;
Code:
$searchonly = $in{'searchonly'};

if ($searchonly eq "company_name") {
@search_fields = (15);
}
elsif ($searchonly eq "town") {
@search_fields = (16);
}
elsif ($searchonly eq "address") {
@search_fields = (14);
}

else {
@search_fields = (1,2,5,14,15,16,17);
}
and then when calling the search query I am using search.cgi?query=something&searchonly=town , which should make @search_fields = (16); , but now for some reason nothing is being searched.

Try http://courier.ace-installer.com/...&searchonly=town.

Now, I know there is a link there with the Town set as Rudgwick, but it just doesn't want to see it. I have tried using a fresh copy of links.def, and re doing it, but it still won't work. Any suggestions? I expect I made a typo error somewhere, but at the moment I can't see it Smile

I'll go and get something to eat and have a rest, and then maybe when i get back someone will have found my stupid error, or I will be a bit more with it and see it myself Blush

Thanks

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: A Script.... In reply to
Ok, I'm back, but still no luck Frown

Anyone got any ideas as to what may be the problem with it? As far as I can see it is ignoring the if / elsif / else statment, but I can't see why.

Thanks

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: A Script.... In reply to
Hello Andy,
you have to add the following code:

Code:
$searchonly = $in{'searchonly'};
if ($searchonly eq "company_name") {
@search_fields = (15);
}
elsif ($searchonly eq "town") {
@search_fields = (16);
}
elsif ($searchonly eq "address") {
@search_fields = (14);
}
else {
@search_fields = (1,2,5,14,15,16,17);
}
to the search.cgi file, NOT the links.def file. Wink

I have instruction to do this here:
http://www.simball.de/...ds/search_only.shtml

For me and other German Links users it work's.

Here an example:

Search only in URL:
http://www.fussballsuche.de/...All&location=dir
Result: 1 category and 4 links

Search only in title:
http://www.fussballsuche.de/...All&location=dir
Result: 1 category and 3 links

Search all:
http://www.fussballsuche.de/...All&location=dir
Result: 1 category and 14 links

Hope that helps.

DelPierro
http://www.simball.de/links_mods/
Quote Reply
Post deleted by schonchin In reply to
Quote Reply
Re: A Script.... In reply to
I've already replied to your DUPLICATE thread.

Regards,

Eliot Lee
Quote Reply
Re: A Script.... In reply to
Thanks so much for pointing out it's a duplicate message. After a day of no replies I decided #1 my query wasn't entirely about the topic in the thread and #2 the listed topic of the thread was so vague as to limit the number of users who would bother taking a look at the thread. Therefore I decided I should have posted my question as a new thread. But thanks for your observation.

Quote Reply
Re: A Script.... In reply to
I'll also take this time to note that if this message forum made it easy to delete messages, I would have gladly deleted my "duplicate" post. It is a matter of poor usability that the 'delete message' function is HIDDEN behind an 'edit' button that clearly implies an an editing function instead of wholesale deletion.