Gossamer Forum
Home : Products : Links 2.0 : Customization :

Again : nonenglish in detailed pages

Quote Reply
Again : nonenglish in detailed pages
Hi,

I have been seriously busy with the non english mod, but I finally made it.

Another problem appeared when I switched to the Detailed page option : the category on top wasn't nonenglish, rather it was displaying th default category.

Here are the links field definitions :


%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
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'],
Question => [14, 'alpha', '40x3', 500, 1, '', ''],
Reponse => [15, 'alpha', '72x3', 64000, 0, '', '']
);

(BTW, I added two fields)


And here are my category definition :

***************************************** nonenglish modification - begin ****************
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 40, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', ''],
Nonenglish => [8, 'alpha', 40, 75, 0, '', '']
);
# ***************************************** nonenglish modification - end ******************

How can I force Links2 to show the correct nonenglish field in detailed pages ??? Thanks for helping a lost soul !

JeB
Quote Reply
Re: Again : nonenglish in detailed pages In reply to
I DID IT

Here's How :

1 - Add a noneglish field to links.def where you put the nonenglish version of Category field.

2 - in nph-build.cgi, edit sub build_detailed_view to show like this :




sub build_detailed_view {
# --------------------------------------------------------
# This routine build a single page for every link.
#

my (@values, $id, %rec, $count);

if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];

# ***************************************** nonenglish for detailed page modification - begin ****************
%rec = &array_to_hash (0, @values);
# $title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");
$title_linked = &build_linked_title_mb ( $values[4], $values[16]);



NOTA : the $values[4] and $values[16] are respectively the 4th and 16th field in %db_ref , corresponding to the Category and Nonenglish field.

That's IT ! JeB
Quote Reply
Re: [JeB] Again : nonenglish in detailed pages In reply to
Hi All

Is there a way to have the sub build_detailed_view routine just read the nonenglish field in categories.db instead of having to add the extra field to links.def? JeB's method does work (Thanks, JeB!), but I'm concerned that it would be easy to lose track of the category names if the site has lots of categories.

Thanks very much

Smile

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