Gossamer Forum
Home : Products : Links 2.0 : Customization :

Tree mod and nonenglish, together at last!

Quote Reply
Tree mod and nonenglish, together at last!
Well, after quite a bit of fiddlin' around, I got the (template-based) tree mod to build using category names from the nonenglish mod! Looking at the changes, it's sad it took so long to do, when it's so easy! The update is still not perfect, as I could not get it to do both (if/else) regular and nonenglish names, so for it to look right, you need an entry in the nonenglish field for ALL of you cats and subcats. Here is an example of what happens if you don't (last in list): History & Doctrine (42)
  • Apologetics (4)
  • Bible Lands (0)
  • History and Doctrine : Creation (14)
But as long as you have a nonenglish entry, you can use anything for the cat name:
  • Teen's (4)
  • Women's (4)
  • TV, Movies, Music & Games (2)
OK, here is the code, from site_html_templates.pl, changes in red:

EDIT: CODE FURTHER DOWN

Note that there is a lot of CSS code in there that is specific to my site; you will need to change them to match your site. See it in action:

http://theonetruechurch.com/links/map/index.html


Leonard
aka PerlFlunkie


Leonard
aka PerlFlunkie

Last edited by:

Andy: Nov 24, 2004, 11:47 PM
Quote Reply
Re: [PerlFlunkie] Tree mod and nonenglish, together at last! In reply to
Thanks for posting :) The code came out a little jumbled though. Did you use the "Advanced Editor"?

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] Tree mod and nonenglish, together at last! In reply to
Andy,

I went into the 'basic' editor to remove some excess stuff that the 'advanced' one would not let me do... Ok, I'll try again:

Code:

sub site_html_print_map {
# --------------------------------------------------------
# This routine builds a tree from all links/categories
my ($cat, $numlinks);
my ($linkstree, $output, @categorylist, $depth_old, $depth_new);
my ($relative_url, $numcat, $cat_per_col, $next_split, $current_cat, $nonenglish, $zcat, $category_name, $category_clean2);
local ($links);

$build_root_url =~ m~http://[^/]*~;
$relative_url = $';
# set linkstree to 0 if you want only a tree of all categories
# set linkstree to 1 if you want a tree off all categories and links
$linkstree = 0;
$depth_old = 0;
$numcat = keys %category;
$cat_per_col = $numcat / $site_map_columns;
$next_split = $cat_per_col;
$current_cat = 0;


# Print Header.
$output = qq|<div id="mid-col-1"><ul>\n|;
# Go through each category and build the appropriate page.
CATEGORY: foreach $cat (sort keys %category) {
next CATEGORY if ($cat =~ /^\s*$/);

$category_clean = &build_clean ($cat);
$zcat = &kategorie_title_mb($cat);



$numlinks = $stats{$cat}[0];
$current_cat++;

@categorylist = split (/ : /, $category_clean);

$depth_new = $#categorylist;
$links = "";
## remove this line >> $zcat = @categorylist[$#categorylist];



if ($depth_new < $depth_old) {
for ($i = 0; $i <= ($depth_old - ($depth_new + 1)); $i++) {
$links .= "\n</ul>";
}
if ($depth_new == 0 && $current_cat > $next_split) {
$next_split += $cat_per_col;
$links .= qq|</ul></div><div id="mid-col-2"><ul>\n|;
}
}
$links .= qq~\n<li><a href="$relative_url/$cat/">$zcat</a><span class="smalltype">&nbsp;($numlinks)</span>~;
if ($linkstree == 1) {
$numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
for ($i = 0; $i < $numlinks; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);
}
$links .= "\n";
}
if ($#{$subcategories{$cat}} >= 0) {
$links .= "\n<ul>";
}
$output .= $links;
$depth_old = $depth_new;
}
$output .= qq|</ul></ul></div>\n|;

return $output;
}


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Nov 24, 2004, 9:42 AM
Quote Reply
Re: [PerlFlunkie] Tree mod and nonenglish, together at last! In reply to
Much better... thanks Cool

I personally don't need this mod, but I know how much easier it is to work with, when you don't have to do loads of formatting, so you can make sense of it <G> (and I know how many people are in need of this mod =)).

Did you want me to remove the code from your first post, or is it still within your editable "timelimit" ?

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] Tree mod and nonenglish, together at last! In reply to
Andy,

No, I cannot edit. (I see that as a bad point in the GTForum script.)

You can delete the code, or put the corrected code in it's place.

Do you see how to get this code to work right:

if ('nonenglish' eq '') {
$zcat = &build_clean ($cat);
}
else {
$zcat = &kategorie_title_mb($cat);
}

I have tried a dozen variations on the theme, but I still get my 'test' category coming up wrong:

History and Doctrine : Creation

instead of just

Creation

Since the 'and' is there, this is not going through the kategorie_title_mb code, which is good, but I want it to leave off the main category name. I also tried using

$zcat = @categorylist[$#categorylist];

to see if it would work as the original tree mod code, but it produces the same result.

Any ideas? Pirate


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Tree mod and nonenglish, together at last! In reply to
Hi PerlFlunkie,
it works perfect
http://www.gpaed.de/...raturtipps/index.php

Thank you very much
Matthias

Matthias
gpaed.de
Quote Reply
Re: [PerlFlunkie] Tree mod and nonenglish, together at last! In reply to
No problem... I've edited it for you :) (the GForum "edit" limit is an option, but most people have it left off).

Quote:
Do you see how to get this code to work right:

Mmm... where is "nonenglish" coming from?

You said you tried;

Code:
$zcat = @categorylist[$#categorylist];

...try this;

Code:
$zcat = $categorylist[$#categorylist];

Does that work? Its a little hard, as I havn't really played with Links2 for quite a while :|

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] Tree mod and nonenglish, together at last! In reply to
Andy,

That didn't change anything. I tried these (among others...) as the definition of nonenglish:

($nonenglish) = $#categorylist;[8];
($nonenglish) = $#categorylist[8];
($nonenglish) = @categorylist = split (/ : /, [8]);

I have also used

($rec{'nonenglish'} eq '') ? $zcat = $category_clean : $zcat = &kategorie_title_mb($cat);

which gives the same results as the 'if' statement. Oh well, it works for me as is, I do have a nonenglish entry for all cats.

Thanks...Unsure


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Tree mod and nonenglish, together at last! In reply to
I don't see where $nonenglish is coming from :/ If you could paste the whole section, with sample values, then I may be able to help you :)

($nonenglish) = $#categorylist;[8];

...wont work, as that is effectivly saying; "The number of entries in categorylist".

($nonenglish) = $#categorylist[8]; .... Similar, in that its trying to reference the $# value, which is an "array count".

:)

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!