Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Category Name question

Quote Reply
Category Name question
Dear all,

Because my site won't use english. So I just want to add one more field in the categories database. So that I can enter the name of that category in my language and the name field will still use english.

I know I can do it easily. But I just don't know how can I display the category name in my language and the category link in english.

Can anyone help?


------------------
Bear EveryWhere
Quote Reply
Re: Category Name question In reply to
use the directory idea i came up with.. ( Smile)

it's now included in Links SQL 1.1

umm... find

$LINKS{build_directory_field}

in Links.pm and it has an explanation there..

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: Category Name question In reply to
Jerry, could you please identify what changes I would need to make in order to use "Categories" in the screen display and "categories" for directory names? I would like for all server files to be created using lowercase lettering while the page display contains mixed case. Thank you! (LinksSQL 1.11 & DBManSQL)

------------------
~ ~ ~ ~ ~
Karen
Quote Reply
Re: Category Name question In reply to
i don't use DBMANSQL.. so I have no clue there..

but all you need to do is add a field to the category database.. example: 'Directory'

and then change

Code:
$LINKS{build_directory_field} = "";

to

Code:
$LINKS{build_directory_field} = "Directory";

also.. i think you'd need to change sub build_clean_name in DB_Utils.pm to this (if you use both foreign and directory fields..)

Code:
sub build_clean_name {
# --------------------------------------------------------
# Converts a category name into something usable by a directory/URL.
#
my $name = shift;
if ($LINKS{build_directory_field}) {
my $id = &get_category_id ($name);
if (! $CATDB) {
$CATDB = new Links: BSQL $LINKS{admin_root_path} . "/defs/Category.def";
}
my $rec = $CATDB->get_record ($id, 'HASH');
if ($rec->{$LINKS{build_directory_field}}) { return $rec->{$LINKS{build_directory_field}}; }
else { $name =~ s/\s/_/g; $name =~ s/[^\w\d\_\-\/]/_/g; return $name; }
}
elsif ($LINKS{foreign_char}) {
my @cat = split /\//, $name;
my ($output, $id, $tmp, $level);
$level = $#cat;
for (0 .. $level) {
$tmp = join "/", @cat;
$id = &get_category_id ($tmp);
if (!$id) { $tmp =~ s/[^\w\d\_\-\/]/_/g; $id = $tmp; }
$output = "$id/$output";
pop @cat;
}
$output =~ s,/$,,;
return $output;
}
else {
$name =~ s/\s/_/g;
$name =~ s/[^\w\d\_\-\/]/_/g;
return $name;
}
}

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: Category Name question In reply to
Thanks Jerry, worked like a champ!

------------------
~ ~ ~ ~ ~
Karen
Quote Reply
Re: Category Name question In reply to
Although foreign_char and directory_field should be mutually exclusive, you shouldn't be using both. =)

Cheers,

Alex
Quote Reply
Re: Category Name question In reply to
Well, now I'm in a pickle! I thought things were okay because the build all function in admin had not generated errors. I just tried accessing different links on the template pages and I am getting compilation errors.

Errors
syntax error at admin/Links/DB_Utils.pm line 401, near "new Links:"
syntax error at admin/Links/DB_Utils.pm line 407, near "elsif"

and
DB_Utils.pm: syntax error at admin/Links/DB_Utils.pm line 401, near "new Links:"
DB_Utils.pm: syntax error at admin/Links/DB_Utils.pm line 407, near "elsif"
BEGIN failed--compilation aborted at /usr/local/etc/httpd/cgi-bin/links/page.cgi line 34.

The offending sections of code are:
Code:
my $name = shift;
if ($LINKS{build_directory_field}) {
my $id = &get_category_id ($name);
if (! $CATDB) {
$CATDB = new Links: BSQL $LINKS{admin_root_path} . "/defs/Category.def"; (line 401)
}
my $rec = $CATDB->get_record ($id, 'HASH');
if ($rec->{$LINKS{build_directory_field}}) { return $rec->{$LINKS{build_directory_field}}; }
else { $name =~ s/\s/_/g; $name =~ s/[^\w\d\_\-\/]/_/g; return $name; }
}
elsif ($LINKS{foreign_char}) { (line 407)

The only changes I've made in addition to this thread are:
http://www.gossamer-threads.com/scripts/forum/resources/Forum9/HTML/000651.html
http://www.gossamer-threads.com/scripts/forum/resources/Forum9/HTML/000601.html

Could/would someone please help me out and identify what corrections are needed? Thank you so much!


------------------
~ ~ ~ ~ ~
Karen


[This message has been edited by Karen (edited February 01, 2000).]
Quote Reply
Re: Category Name question In reply to
I think you got a cut and paste error from the forum. The change to DB_Utils.pm isn't neccessary if you don't use foreign_char option. I would start with your original DB_Utils.pm and work with that.

Cheers,

Alex