Gossamer Forum
Home : Products : Links 2.0 : Customization :

Trouble with search for all languages...

Quote Reply
Trouble with search for all languages...
Hello

i've added a field in links.def for language, and donw for drop box.
i've used upgrade.pb because i've got some links in my links.db ;o)
After i've added some codes in links.html for pics of languages.
It works.

I wanted to propose search by languages,
so i've added some codes in search.cgi, search.html.

It's allright for german, english... language, but not with the option "all". I've got : "No match found".

I think that i've made a mistake, and "all" is understand like the language "all", like "german, french..."

But when i didn't put "all" in %db_select_fields in links.def, it's not allright for "all" but for "german", "enghlish..." yes!

This are the codes i've added, thanks for your help...

* 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'],
Pic => [14, 'alpha', 40, 100, 0, '', ''],
langue => [15, '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 = 15;

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


* 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',
langue => 'All,Allemand,Anglais,Espagnol,Français,Italien',
ReceiveMail => 'Yes,No'
);

* 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="Français">Français</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 for your help.

Ciao

PS: i've searched in the forum, but i didn't find any answer, there will be a lot of posts,
i've put : search all search.cgi with AND option, but there will be so many posts.


Quote Reply
Re: Trouble with search for all languages... In reply to
Hi there,

just to prevent, here's a spontanious idea I had about his - your (old) links already include the (new) language item?
Wink

Denis

Quote Reply
Re: Trouble with search for all languages... In reply to
Hello

Good idea... :o)
but yes, all links have the (new) language item...
And search with "all" doesn't work!
If i could not use "all", is it possible to disactive the search with language?
So i could propose in advanced search with language : search by english, german, french... and All (equal to the disactived searched by language).

I hope i was clear, please don't hesitate to tell me...

Thanks for your help

ciao

Quote Reply
Re: Trouble with search for all languages... In reply to
The following codes are problematic:

Code:

langue => 'All,Allemand,Anglais,Espagnol,Français,Italien',


You do not need to have All as a value as it will conflict with Widgetz's codes for the language search codes in the search.cgi file. You should either change the All value to something like Every in the %db_select_field hash.

Or you could change the All value in your search codes (both in the search.cgi and search.html) to Every.

Regards,

Eliot Lee
Quote Reply
Re: Trouble with search for all languages... In reply to
Eliot thanks for your help! :o)

I've taken off "all" in language
And Db_field is now like this :
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No',
langue => 'Allemand,Anglais,Espagnol,Français,Italien',
ReceiveMail => 'Yes,No'
);

But I've still got the problem with the search with all language.

Is the code that i've put in search.cgi good and in the good place? (i believe it's the code you have proposed in a post)

Thanks

Ciao

PS: I don't believe that i used Widgetz's codes for the language search codes in the search.cgi file. I've taken it from this forum, but perhaps i's a post from or inspired by Widgetz ;o)

Quote Reply
Re: Trouble with search for all languages... In reply to
Uh...the codes you have are fine and THEY ARE adapted codes from Widgetz's CATEGORY SEARCH codes.

Wink

Don't know what to tell you...

Regards,

Eliot Lee
Quote Reply
Re: Trouble with search for all languages... In reply to
HEllo

Uh...the codes you have are fine and THEY ARE adapted codes from Widgetz's CATEGORY SEARCH codes.
* ok ;o)

Is it possible that there is a problem with the "ç" of "français"?

thanks

Quote Reply
Re: Trouble with search for all languages... In reply to
Possibly...however...if you are able to find links with that language value...then that is not the problem. If you cannot find values for Francais...then I would suggest taking out the accent characters in the language values in both your links.def and links.db files.

Regards,

Eliot Lee
Quote Reply
Re: Trouble with search for all languages... In reply to
Hello!

Thank U for your help Eliot :o)

Search with français value works.
But i've found a strange bug :
"All" works if I used OR connector , but if I used "And" connector search engine says : "Error : No match records found". (Add is in default in "my" links)

Very strange...
What is my mistake?
Do have someone use search by one field, and all value of this field? i'm sure yes, but with any pb?

Thanks.

ciao

PS : "And" connector (and "or") works fine with "anglais", "français" "german"...