Gossamer Forum
Home : Products : Links 2.0 : Customization :

Problem with the nonenglish mod (bug?)

Quote Reply
Problem with the nonenglish mod (bug?)
I'm not sure if it's a bug or that it is my mistake, but the nonenglish mod doesn't work 100% right here.

On the What's new pages the script uses my original category name (instead of the nonenglish title). To be honest: it's now even worse than before, because the script doesn't filter the "_" in de category name.

I.e. A category with the name "A and B" and the nonenglish title "A & B" has created the directory "A_en_B". When I browse the categories, the script uses the nonenglish title "A & B" so that's fine. But on the What's new pages there is a problem (bug?). On the What's new pages I get "A_and_B" as category title?

Am I the only one with this problem?

Another question: How can I modify the script in that way that the nonenglish titles will be used in the dropdown box that you get when you want to add/modify a link?

C.
Quote Reply
Re: [C.] Problem with the nonenglish mod (bug?) In reply to
Did you make the change in nph-build.cgi, at sub build_new_page? Like so:

# ***************************************** nonenglish modification - begin ****************
# $category_clean = &build_clean ($category);
$category_clean = &kategorie_title_mb ($category);
# ***************************************** nonenglish modification - end ******************

I have not been able to get the dropdowns to work like you (and I) would like.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Problem with the nonenglish mod (bug?) In reply to
If you paste the full mod (or a URL), I'll have a go at fixing this for you. Should just be a case of some regex here and there Smile

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] Problem with the nonenglish mod (bug?) In reply to
Yo Andy,

Do you mean the dropdown? The nonenglish mod is here: http://www.gossamer-threads.com/...rsion_2_x/index.html, the second one down. The code for the dropdown is like so:

From site_html_templates.pl:


sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;

my $category = shift;
# ***************************************** nonenglish modification - begin ****************
# $category ?
# ($category = qq~$category <input type=hidden name="Category" value="$category">~) :
# ($category = &build_select_field ("Category", "$in{'Category'}"));
my ($kategorie) = &kategorie_title_mb ($category);
$category ?
($category = qq~$kategorie <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));
# ***************************************** nonenglish modification - end ******************

print &load_template ('add.html', {
Category => $category,
%globals
});
}

And from db_utils.pl

sub build_select_field {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $mult) = @_;
my ($size, %values);

$name || ($name = $column);
$size || ($size = 1);

if (! exists $db_select_fields{$column}) {
$db_select_fields{$db_cols[$db_category]} = $db_select_fields{'Mult-Related'} = join (",", &category_list);
}
if ($mult) {
@fields = split (/\,/, $db_select_fields{"Mult-$column"});
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
@fields = split (/\,/, $db_select_fields{$column});
$values{$value}++;
}
($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";

$output = qq|<SELECT NAME="$name" $mult SIZE=$size><OPTION>---|;

## next changed LT for nonenglish mod **********

foreach $field (@fields) {
$kategory{$field} = &kategorie_title_mb1($field);

$values{$field} ?

($output .= "<OPTION SELECTED VALUE=\"$field\">$kategory{$field}\n") :
($output .= "<OPTION VALUE=\"$field\">$kategory{$field}");
}
## end LT nonenglish*****************

$output .= "</SELECT>";
return $output;
}

The dropdowns now show like so-- category : sub and category, but in the nonenglish they are entered as category : sub & category


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Problem with the nonenglish mod (bug?) In reply to
If you replace;

$kategory{$field} = &kategorie_title_mb1($field);

with...

$kategory{$field} = &kategorie_title_mb1($field);
$kategory{$field} =~ s/ and / & /g;

...does that fix it? I've never used this mod before... so I'm just guessing with it.

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: [PerlFlunkie] Problem with the nonenglish mod (bug?) In reply to
In Reply To:
Did you make the change in nph-build.cgi, at sub build_new_page? Like so:

# ***************************************** nonenglish modification - begin ****************
# $category_clean = &build_clean ($category);
$category_clean = &kategorie_title_mb ($category);
# ***************************************** nonenglish modification - end ******************

I have not been able to get the dropdowns to work like you (and I) would like.


Yes, I did... I've just checked it. I also rebuilt the pages and suddenly the problem was gone. Very weird, but it must have been a silly mistake from me. Sorry to bother you guys with this.

C.
Quote Reply
Re: [Andy] Problem with the nonenglish mod (bug?) In reply to
C., glad ya got it workin!

Andy, I see no difference in my dropdown with that bit of code... I spent several hours on that problem a few months ago, with varying results, but none I liked better than what presently appears. Oh well... Unsure


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Problem with the nonenglish mod (bug?) In reply to
In Reply To:
C., glad ya got it workin!

Andy, I see no difference in my dropdown with that bit of code... I spent several hours on that problem a few months ago, with varying results, but none I liked better than what presently appears. Oh well... Unsure


I've just noticed this problem has already been solved. Crazy Check this topic: http://gossamer-threads.com/...mp;ubb=005341:Forum3

I've just tried it and it works fine! Smile

C.

Last edited by:

C.: Sep 3, 2003, 10:18 AM
Quote Reply
Re: [C.] Problem with the nonenglish mod (bug?) In reply to
I read that before, but still had no success. Post the whole sub you changed, maybe i can see what I missed... It is sub build_select_field_from_db, right?


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Problem with the nonenglish mod (bug?) In reply to
In Reply To:
I read that before, but still had no success. Post the whole sub you changed, maybe i can see what I missed... It is sub build_select_field_from_db, right?


In db_utils.pl search for sub build_select_field. This is the entire sub build_select_field I'm using right now:

Code:
sub build_select_field {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $mult) = @_;
my ($size, %values);

$name || ($name = $column);
$size || ($size = 1);

if (! exists $db_select_fields{$column}) {
$db_select_fields{$db_cols[$db_category]} = $db_select_fields{'Mult-Related'} = join (",", &category_list);
}
if ($mult) {
@fields = split (/\,/, $db_select_fields{"Mult-$column"});
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
@fields = split (/\,/, $db_select_fields{$column});
$values{$value}++;
}
($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";

$output = qq|<select class="form" name="$name" $mult size=$size><option>---|;
foreach $field (@fields) {
$kategory{$field} = &kategorie_title_mb($field);
}

foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED VALUE=\"$field\">$kategory{$field}\n") :
($output .= "<OPTION VALUE=\"$field\">$kategory{$field}");
}
$output .= "</select>";
return $output;
} sub kategorie_title_mb {
# --------------------------------------------------------
my ($input, $output, $title, $kategorie, @fields); $input = $_[0];
$title = ""; KATEGORIE: foreach $kategorie (@kategorien) {
if ($kategorie =~ /^#/) { next KATEGORIE; } # Skip comment lines.
chomp ($kategorie);
@fields = &split_decode ($kategorie);
if ($fields[1] eq $input) {
$title = $fields[8];
last KATEGORIE;
}
}
if ($title eq "") {
$output = &build_clean ($input);
}
else {
$output = &build_clean_mb ($title);
} return $output;
}


Don't forget to include the sub kategorie_title_mb below the sub build_select_field (like I did above). Otherwise the validation of new links won't work...

C.

Last edited by:

C.: Sep 4, 2003, 5:24 PM
Quote Reply
Re: [C.] Problem with the nonenglish mod (bug?) In reply to
Well, I got it using nonenglish dropdowns in the admin section, but still not on the user-viewable page (add.cgi). I'll fiddle more later, thanks for helping!Tongue


Leonard
aka PerlFlunkie