Gossamer Forum
Home : Products : Links 2.0 : Customization :

Is anybody successed with search by field (Widgetz

Quote Reply
Is anybody successed with search by field (Widgetz
Hello

I've got a strange problem with Eliot's adapted codes from Widgetz's CATEGORY SEARCH codes... (i believe it's Eliot's adapted, but i'm not sure...)!

I've added a field called "langue". I want to propose "search by language".
So I've added the following adapted codes from Widgetz, after ++grand_total in search.cgi :
if ($in{'langue'} && $in{'langue'} ne "All") {
($values[$db_langue] =~ /^$in{'langue'}/) or next LINE;
}

Advanced search works fine for : french, german, american... language, but not with ALL language with "AND" connector. It's allright with "ALL" and "OR", but not with "ALL" and "AND"!

"All" language + "AND" works only for the search in categories but no in the links (title, description...).

Is anybody have succed in this way???
I've spent a lot of time to find the solution, reinstall 2 times links, read a lot of posts, but there's still a problem...

Thanks for your help!
U could see the problem at : www.ilaoo.com/lpages with advanced search.

----------------------------------

Please find codes I've added :

* In links.def :
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
langue => [14, 'alpha', 40, 100, 0, '', '']);

* In links.def :
# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_langue = 14;

* In links.def:
# Field names you want to allow visitors to search on:
@search_fields = (1,2,5,14);


* In links.def :
# Hash of column names to possible options. If you want to use a select form
# field, you can use &build_select_field in your HTML page. This routine will
# make a <SELECT> input tag using the following values:
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
ReceiveMail => 'Yes,No',
langue => 'Allemand,Anglais,Espagnol,Francais,Italien'
);

* In search.cgi :
# Go through the database.
open (DB, "<$db_file_name") or &cgierr("error in search. unable to open database: $db_file_name. Reason: $!");
flock (DB, 1) if ($db_use_flock);
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
$grand_total++;
if ($in{'langue'} && $in{'langue'} ne "All") {
($values[$db_langue] =~ /^$in{'langue'}/) or next LINE;
}


* In search.html with templates :

<form action="<%db_cgi_url%>/search.cgi" method="GET">
<div class="margin">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>Search: <input type="TEXT" name="query" size="30"> <input type="Submit" value="Search"></td></tr>
<tr><td>Number of Results: <SELECT name="mh"><OPTION>10<OPTION SELECTED>25<OPTION>50<OPTION>100</SELECT></td></tr>
<tr><td>Langue: <select name="langue">
<option value="All">All</option>
<option value="Allemand">Allemand</option>
<option value="Anglais">Anglais</option>
<option value="Espagnol">Espagnol</option>
<option value="Francais">Francais</option>
<option value="Italien">Italien</option>
</select></td></tr>
<tr><td>As Keywords: <input type="RADIO" name="type" value="keyword" CHECKED> As Phrase: <input type="RADIO" name="type" value="phrase"></td></tr>
<tr><td>AND connector: <input type="RADIO" name="bool" value="and" CHECKED> OR connector: <input type="RADIO" name="bool" value="or"></td></tr>
</table>
</div>
</form>


Thanks


PS : This post is the suite of the following : http://www.gossamer-threads.com/...w=collapsed&sb=5
PS2 : If U wanted add some images or flags with language or links, there is a good thread here :
http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/002723.html
Subject Author Views Date
Thread Is anybody successed with search by field (Widgetz jude 2653 Jul 4, 2000, 3:13 PM
Thread Re: Is anybody successed with search by field (Widgetz
jude 2562 Jul 7, 2000, 5:31 AM
Thread Re: Is anybody successed with search by field (Widgetz
Bobsie 2542 Jul 7, 2000, 3:03 PM
Thread Re: Is anybody successed with search by field (Widgetz
jude 2524 Jul 8, 2000, 4:19 AM
Thread Re: Is anybody successed with search by field (Widgetz
jude 2512 Jul 8, 2000, 8:04 AM
Thread Re: Is anybody successed with search by field (Widgetz
jude 2514 Jul 8, 2000, 8:38 AM
Post Re: Is anybody successed with search by field (Widgetz
jude 2491 Jul 9, 2000, 5:10 AM
Thread Re: Is anybody successed with search by field (Widgetz
jude 2465 Jul 10, 2000, 5:33 AM
Thread Re: Is anybody successed with search by field (Widgetz
jude 2435 Jul 11, 2000, 2:20 PM
Post Re: Is anybody successed with search by field (Widgetz
jude 2365 Nov 11, 2000, 2:52 AM