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
Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
Is there another way to add and search by field???

thanks

Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
See the messages from Alex in the thread at:
http://www.gossamer-threads.com/...ew=&sb=&vc=1

I hope this helps.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
Hello Bobsie

Thanks for your help :o)

I've allready seen the post you told me, but perhaps i don't read very good. So with a rereading of it i've got few questions...

Eliot said that the codes i've used are good,
but Ceglobe have proposed a different way in the post.

* I've put in search.cgi :
if ($in{'langue'} && $in{'langue'} ne "All") {
($values[$db_langue] =~ /^$in{'langue'}/) or next LINE;
}

* And Cegoble :
if ($in{'category'}){
($in{'category'} eq $values[$db_category]) or next LINE;
}

(category=langue in this example)

* I've put in search.html with templates :
<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>

* And Cegblobe have put codes in site_html.pl, in sub site_html_search :
<select name=database_field><option>option 1<option>option 2<option>etc....</select>

Which way is best?
Thanks for your help, i'm going crazy ;o)
I'm closed to success, except search with "All" and "And", all is good.

ciao



Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
HEllo

I'm a success with my problem :o))))))))

With Alex"s code :
Edit search.cgi and look for:
exists $in{$db_cols[$_]} and (push (@field_search, $_));
and change that to:
$in{$db_cols[$_]} and (push (@field_search, $_));

Search with "ALL" value and "AND" connector seems to work fine!
Hope there is no trouble with delete "exists"!!!

If U wanted to add field, add flag, picture, logos... and search by field, I could help U!!!

Thanks ELIOT, Alex, Bmxer, Widgetz, Alex and the other that i've forgotten for their help and/or their codes!!!

Ciao


Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
Eheh...

There's still a little problem ;o)

Search by specific value like "english" with OR connector
gives all links with this value (english) :o(
Now, only "all" value works fine, it's ironic !

I've got the same problem that Nedlas at the post :
http://www.gossamer-threads.com/perl/forum/showflat.pl?Cat=&Board=L2Cust&Number=83545&page=0&view=collapsed&sb=5

Any idea?

thanks
Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
Thank for your help too Bobsie,
i've forgotten U,
i'm confused ;o)

Ciao

Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
Hello

Me again ;o)

I think the problem with "OR" and search by specific field like "english" is (perhaps) because
when I made an advanced search by "english" value + OR connector(or + AND connector) with no word or just a space, search engine gives all links with english language.


With "All" language it isn't possible to make search with no keyword or space (message : please enter one or more keywords), so there is no problem with "all" value + OR connector!


So how can I block search with no keyword or just space with "english", "deutsh" ... values ???

Thanks a lot for your help

PS: there is perhaps another problem with specific value search :
If I made a search with "english", and put keyword : CAT,
search engine will search in links.db "english + cat" or only "cat" in links with "english" value?
If it was the first way, it's perhaps another reason of the trouble with "OR"...
PS 2 : Tell me if i was not clear.


Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
Hello

i've added this line in search.cgi
if (!$tmp and !@langue_search) { return ("Please enter one or more keywords."); }

after :
$grand_total++;
if ($in{'langue'} && $in{'langue'} ne "all") {
($values[$db_langue] =~ /^$in{'langue'}/) or next LINE;
}


Now, blank request isn't allow with advanced search by language field,
but with "OR" and language value (except all language)
it still doesn't work...

Hope someone have an idea!

i've read all post in forum customization with SEARCH+FIELD,
advanced+search... it takes me 2 days, but i've found no solution ...

Thanks

Quote Reply
Re: Is anybody successed with search by field (Widgetz In reply to
Hello

Domenic have found the solution of this problem :
In links.def
langue field should be call Langue and not langue

And now it's allright!

Thanks for all guys and girls Laugh
Special thanks to Domenic, Eliot, Denis, Simon, Nicky, Jerry... and all people that i've forgotten!

See U soon
Jude