Gossamer Forum
Home : Products : Links 2.0 : Customization :

nonenglish mod breadcrumb nav

Quote Reply
nonenglish mod breadcrumb nav
I have tried and tried to fix the navigation problem that seems common with the nonenglish mod:

How it is: Home » » checkin' out the mods!

How it should be: Home » this, is a test & such » checkin' out the mods![/quote]
See the real thing here[/url].[/url]



Thanks!Crazy


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Sep 4, 2002, 3:21 PM
Quote Reply
Re: [PerlFlunkie] nonenglish mod breadcrumb nav In reply to
Hi All

Any luck with breadcrumb and nonenglish?

It's the title_linked thing that needs to be tweaked. When using the nonenglish, it doesn't display the full breadcrumb - only the beginning and end.

Should be:

Top:Shoes:Leather:Red

But nonenglish shows:

Top:Red

Here's the original build_linked_title:

Code:
sub build_linked_title {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my $input = shift;
my (@dirs, $dir, $output, $path, $last);

@dirs = split (/\//, $input);
$last = &build_clean(pop @dirs);

$output = qq| <A HREF="$build_root_url/">Home</a> :|;
foreach $dir (@dirs) {
$path .= "/$dir";
$dir = &build_clean ($dir);
$output .= qq| <A HREF="$build_root_url$path/">$dir</a> :|;
}
$output .= " $last";

return $output;
}


Here's the nonenglish build_linked_title_mb:

Code:
sub build_linked_title_mb {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my ($input) = $_[0];
my ($description) = $_[1];
my (@dirs, $dir, $output, $path, $last, @descs, $desc);

@dirs = split (/\//, $input);
@descs = split (/\\/, $description);
$last = pop (@dirs);
$last = pop (@descs);

$output = qq| <A HREF="$build_root_url/">Home</a> :|;
foreach $dir (@dirs) {
$path .= "/$dir";
$desc = shift (@descs);
$output .= qq| <A HREF="$build_root_url$path/">$desc</a> :|;
}
$output .= " $last";

return $output;
}

This also needs to be fixed for detailed pages.

I've been plugging away, but nothing, yet....dang it!

Thanks....time for some zzzzzzzzzzzzz

Smile

------------------------------------------
Quote Reply
Re: [PerlFlunkie] nonenglish mod breadcrumb nav In reply to
The breadcrumb code seems to work in the author's site:

http://www.schachbund.de/..._Seiten/Oesterreich/

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

Last edited by:

DogTags: Dec 16, 2003, 5:09 AM
Quote Reply
Re: [PerlFlunkie] nonenglish mod breadcrumb nav In reply to
Okay, I found the following thread.

I plugged this into nph_build and got a linked breadcrumb trail in category pages, but it's using the category name, not the nonenglish version of the cat name. Also, it needs the Top link added:

http://www.gossamer-threads.com/...ish%20search;#165423

Should be:

Top > Shoes and Boots > Leather > Red

But nonenglish shows (with code from other thread):

shoes_and_boots > leather > red

------------------------------------------
Quote Reply
Re: [DogTags] nonenglish mod breadcrumb nav In reply to
I currently don't have this nav sysytem in place, but I did before, and I'm pretty sure it worked OK. Check out this code from nph-build.pl:

[See also, http://www.gossamer-threads.com/...g=nonenglish;#235342]



sub build_category_pages {
# --------------------------------------------------------
# This routine builds all the category pages. Each category uses
# the same template which is defined in &site_html_category.

my $build_single = shift;

my ($cat, $url, $dir, @related, $relation, $page_num, $next_page, $numlinks);
local ($category, $links, $title_linked, $title, $total, $category_name, $category_name_escaped);
# ***************************************** nonenglish modification - begin ****************
# local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev);
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $nonenglish, $next, $prev);
# ***************************************** nonenglish modification - end ******************

# Go through each category and build the appropriate page.
CATEGORY: foreach $cat (sort keys %category) {
########################################################
#LT replaced this with next two lines: CATEGORY: foreach $cat (sort keys %category) {
#1 sub byfield { $category{$a}[$cat_sort_field] <=> $category{$b}[$cat_sort_field] };
#2 CATEGORY: foreach $cat (sort byfield @cat) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)
next CATEGORY if ($build_single and ($build_single ne $cat));

$url = "$build_root_url/" . &urlencode($cat) . "/";
$use_html ?
print qq|Building Category: <A HREF="$url" TARGET="_blank">$cat</A>\n| :
print qq|Building Category: $cat\n|;
print "\tSubcategories: " . ($#{$subcategories{$cat}} + 1) . "\n";
print "\tLinks: " . (($#{$links{$cat}}+1) / ($#db_cols+1)) . "\n";

# Let's make sure the directory exists, build it if it doesn't.
$dir = &build_dir ($cat);
print "\tDirectory: $dir\n";
print "\tFilename : $dir/$build_index\n";

# We set up all the variables people can use in &site_html.pl.
# ***************************************** nonenglish modification - begin ****************
# ($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$category{$cat}}[2..7];
($description, $related, $meta_name, $meta_keywords, $header, $footer, $nonenglish) = @{$category{$cat}}[2..8];
# ***************************************** nonenglish modification - end ******************

# Calculate the related entries and put in a <LI> list.
@related = split(/\Q$db_delim\E/, $related); $related = "";
foreach $relation (@related) {
$related .= qq|<li><a href="$build_root_url/|;
$related .= &urlencode($relation);
$related .= qq|/$build_index">|;
# ***************************************** nonenglish modification - begin ****************
# $related .= &build_clean($relation);
$related .= &kategorie_title_mb($relation);
# ***************************************** nonenglish modification - end ******************
$related .= "</a></li>";
}

# Get the header and footer from file if it exists, otherwise assume it is html.
if ($header && (length($header) < 20) && ($header !~ /\s+/) && (-e "$db_header_path/$header")) {
open (HEAD, "<$db_header_path/$header") or &cgierr ("Unable to open header file: $db_header_path/$header. Reason: $!");
$header = "";
while (<HEAD>) {
$header .= $_;
}
close HEAD;
}
if ($footer && (length($footer) < 20) && ($footer !~ /\s+/) && (-e "$db_footer_path/$footer")) {
open (FOOT, "<$db_footer_path/$footer") or &cgierr ("Unable to open footer file: $db_footer_path/$footer. Reason: $!");
$footer = "";
while (<FOOT>) {
$footer .= $_;
}
close FOOT;
}
# ***************************************** nonenglish modification - begin ****************
# $title_linked = &build_linked_title ($cat);
# $title = &build_unlinked_title ($cat);
# $total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
# $category_name = $cat;
# $category_name_escaped = &urlencode ($cat);
# $category_clean = &build_clean ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);

##!!begin nonenglish fix**************************

@categorylist = split (m:/:, $cat);
$depth_new = $#categorylist;
if ($depth_old >= $depth_new) {
for ($i = $depth_new; $i <= $depth_old; $i++) {
pop(@kategorylist);
}
}
$depth_old = $depth_new;
if ($nonenglish eq "") {
push(@kategorylist, $categorylist[$#categorylist]);
$title_linked = &build_linked_title ($cat);
$title = &build_unlinked_title ($cat);
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);
}
else {
push(@kategorylist, $nonenglish);
$nonenglishfull = join('/', @kategorylist);
$title_linked = &build_linked_title_mb ($cat, $nonenglishfull);
$title = &build_clean_mb ($cat, $nonenglishfull);
##XXXXXXXXXXXXXXXXXXXXXXXXXXXXX^^^^^^^^
$category_name = &build_last_title_mb ($nonenglish);
$category_name_escaped = &build_last_title_mb ($nonenglish);
$category_clean = &build_clean_mb ($nonenglish);
}


##!!End fix****************************

# ***************************************** nonenglish modification - end ******************

# Store all the category html info in $category.
if ($#{$subcategories{$cat}} >= 0) {
$category = &site_html_print_subcat (@{$subcategories{$cat}});
}
else {
$category = "";
}

# If we are spanning pages, we grab the first x number of links and build
# the main index page. We set $numlinks to the remaining links, and we remove
# the links from the list.
$numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$next = $prev = $links = "";
if (($numlinks > $build_links_per_page) && $build_span_pages) {
$page_num = 2;
$next = $url . "more$page_num$build_extension";
for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);
}
@{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}];
$numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1);
}
# Otherwise we either only have less then x number of links, or we are not
# splitting pages, so let's just build them all.
else {
for ($i = 0; $i < $numlinks; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);

}
}

# Create the main page.
open (CAT, ">$dir/$build_index") or &cgierr ("unable to open category page: $dir/$build_index. Reason: $!");
print CAT &site_html_category;
close CAT;

# Then we go through the list of links and build on the remaining pages.
$prev = $url if ($build_span_pages);
while ($next && $build_span_pages) {
if ($numlinks > $build_links_per_page) {
$next_page = $page_num+1;
$next = $url . "more$next_page$build_extension";
}
else {
$next = "";
}
$links = "";
LINK: for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
last LINK if ($tmp{$db_key} eq "");
$links .= &site_html_link(%tmp);
}

# ***************************************** nonenglish modification - begin ****************
# $title_linked = &build_linked_title ("$cat/Page_$page_num/");
# $title = &build_unlinked_title ("$cat/Page_$page_num/");
if ($nonenglish eq "") {
$title_linked = &build_linked_title ("$cat/Page_$page_num/");
$title = &build_unlinked_title ("$cat/Page_$page_num/");
}
else {

##!!begin nonenglish fix************************
$title_linked = &build_linked_title_mb ("$cat/Page_$page_num/", "$nonenglish\\Page $page_num\\");
$title = &build_clean_mb ("$nonenglish\\Page $page_num\\");
}
##!!end fix********************


# ***************************************** nonenglish modification - end ******************

$use_html ?
print qq|\tSubpage : <A HREF="|, $url, qq|more$page_num$build_extension" TARGET="_blank">$dir/more$page_num$build_extension</A>\n| :
print qq|\tSubpage : $dir/more$page_num$build_extension\n|;

open (CAT, ">$dir/more$page_num$build_extension") or &cgierr ("unable to open category page: $dir/index$page_num$build_extension. Reason: $!");
print CAT &site_html_category;
close CAT;

@{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}];
$numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1);

$prev = $url . "more$page_num$build_extension";
$page_num++;
}
print "\n";
}
}


And these may or not be different than what you have:

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;
}

sub build_clean_mb {
# --------------------------------------------------------
my ($input) = $_[0];
$input =~ s,\\, : ,g;
return $input;
}

sub build_last_title_mb {
# --------------------------------------------------------
my ($input) = $_[0];
my (@descs, $output);

@descs = split (/\//, $input);
$output = pop (@descs);

return $output;
}

sub build_linked_title_mb {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my ($input) = $_[0];
my ($description) = $_[1];
my (@dirs, $dir, $output, $path, $last, @descs, $desc);


@dirs = split (/\//, $input);
@descs = split (/\//, $description);
$last = pop (@dirs);
$last = pop (@descs);

$output = qq|<a class="smallnav" href="$build_root_url/top">Top</a> &#187;|;
foreach $dir (@dirs) {
$path .= "/$dir";
$desc = shift (@descs);

$output .= qq| <a class="smallnav" href="$build_root_url$path/">$desc</a> &#187;|;
}
$output .= " $last";

return $output;
}


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Dec 16, 2003, 11:17 AM
Quote Reply
Re: [PerlFlunkie] nonenglish mod breadcrumb nav In reply to
While searching for something else, I found this thread. I have not tried it yet, but it looks like a good patch for one of the nonenglish mods' glitchs.

http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=124871#124871


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] nonenglish mod breadcrumb nav In reply to
Thanks, Leonard. I'll take a look.

Much appreciated Smile

------------------------------------------
Quote Reply
Re: [PerlFlunkie] nonenglish mod breadcrumb nav In reply to
Hey Leonard

Here is the link from the thread you mentioned:

http://www.simball.de/...mod_nonenglish.shtml

I gave it a try. Here's what happened:

It should be:

Top: Shoes » Leather » Red
Top: Shoes » Leather » Red-Page 2
Top: Shoes » Leather » Red-Page 3

But what I got was:

Top : » » » Red-Page 2 (notice the extra » as well)

I tried to swap out your fix for the title_linked and title and adjust it for page numbers (cuz it worked great for the other breadcrumb issue), but no luck:

Code:
##!!begin nonenglish fix**************************

@categorylist = split (m:/:, $cat);
$depth_new = $#categorylist;
if ($depth_old >= $depth_new) {
for ($i = $depth_new; $i <= $depth_old; $i++) {
pop(@kategorylist);
}
}
$depth_old = $depth_new;
if ($nonenglish eq "") {
push(@kategorylist, $categorylist[$#categorylist]);
# $title_linked = &build_linked_title ($cat); ## ORIG
# $title = &build_unlinked_title ($cat); ## ORIG
$title_linked = &build_linked_title ("$cat/Page_$page_num/");
$title = &build_unlinked_title ("$cat/Page_$page_num/");
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);
}
else {
push(@kategorylist, $nonenglish);
$nonenglishfull = join('/', @kategorylist);
# $title_linked = &build_linked_title_mb ($cat, $nonenglishfull); ## ORIG
# $title = &build_clean_mb ($cat, $nonenglishfull); ## ORIG
$title_linked = &build_linked_title_mb ("$cat/Page_$page_num/", "$nonenglish\-Page $page_num");
$title = &build_clean_mb ("$nonenglish\-Page $page_num");
##XXXXXXXXXXXXXXXXXXXXXXXXXXXXX^^^^^^^^
$category_name = &build_last_title_mb ($nonenglish);
$category_name_escaped = &build_last_title_mb ($nonenglish);
$category_clean = &build_clean_mb ($nonenglish);
}

##!!End fix****************************

Any suggestions?

Many thanks

Merry Christmas One and All !! SmileSmile

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

Last edited by:

DogTags: Dec 23, 2003, 5:48 AM
Quote Reply
Re: [DogTags] nonenglish mod breadcrumb nav In reply to
Code:
$title_linked = &build_linked_title_mb ("$cat/Page_$page_num/", "$nonenglish\-Page $page_num");
$title = &build_clean_mb ("$nonenglish\-Page $page_num");

Okay, I had to change $nonenglish to $nonenglishfull, and it worked:

Code:
$title_linked = &build_linked_title_mb ("$cat/Page_$page_num/", "$nonenglishfull\-Page $page_num");
$title = &build_clean_mb ("$nonenglishfull\-Page $page_num");

The only problem is that I still get an extra » in the breadcrumb trail. An empty link is being created for that last '»' as well:

Top: Shoes » Leather » » Red-Page 3
<a HREF="http://www.mysite.com/pages/shoes/leather/red/"></a> »

This relates to the sub build_linked_title_mb:

Code:
sub build_linked_title_mb {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my ($input) = $_[0];
my ($description) = $_[1];
my (@dirs, $dir, $output, $path, $last, @descs, $desc);

@dirs = split (/\//, $input);
@descs = split (/\//, $description);
$last = pop (@dirs);
$last = pop (@descs);

$output = qq| <A HREF="$build_root_url/">Top</A> :|;
foreach $dir (@dirs) {
$path .= "/$dir";
$desc = shift (@descs);
$output .= qq| <A HREF="$build_root_url$path/">$desc</A> »|;
}
$output .= "<B> $last</B>";

return $output;
}

######## begin new build_title_linked_mb #########

Would anyone know how to strip out the '»' after the last subcat, but before the 'Page...' display?

Perhaps a different sub could be created and tweaked:

sub build_linked_span_mb

Also, it would be great to fix this for Detailed pages, as well.

Thanks

Smile

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

Last edited by:

DogTags: Dec 27, 2003, 7:15 AM
Quote Reply
Re: [DogTags] nonenglish mod breadcrumb nav In reply to
Been trying to get this to work on the Detail pages, but ugh, no luck.

It seems that the Detail build routines are not reading the category fields.

I can put a link tag on the detail page, and it comes up fine, but if I put a category tag, it doesn't come up.

Any suggestions?

Thanks Smile

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