Okay, I've managed to get the basic idea of 'Alphabar' mod across, but I'm not sure how usable it is in its current state. (I haven't spent too much time on it)
It's a table
added to the top of the 'normal' sub-category table, so it cannot be placed separately at the moment.
It would be better if the alphabar table used a seperate tag, then it could be placed anywhere! It also doesn't 'remove' the Alphabar cats from the normal column count, so the 'normal' categories end up all over the place, but you can get the basic idea.
I had problems with strict when trying to port the counter from my 1.13 mod, so someone else may have to help with this part! What is
should do, is to count the number of 'Alphabar' subcategories and
remove x many from the 'normal' column count so that the calculation used to split the columns in two has the correct
total normal sub-cats and the normal sub-cats display evenly.
Anyway, here's what I've got so far:
Add a new field to the
Category table:
Column Name:
Alphabar Column Type:
ENUM(No, Yes) Not Null:
Yes Default:
No Form Display:
TEXT Make a copy of your
subcategory.html template, and name it 'alphabar.html' (
remove any <li> type formatting in since alpha-cats are not in a DIR type list!)
Now we edit
sub site_html_print_cat { in
SiteHTML.pm:
Note: $output has been changed to
$cattable Code:
sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my ($output, $category_name, $category_url, $i, $cat, $cat_r, @subnames,
$cattable, $alphatable, $category_alpha);
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_colum
ns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
# Print Header.
$alphatable = qq|<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td width="100%" valign="top">\n|; my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
if ($CFG->{build_category_columns}) {
$cattable = qq|<table $table_head><tr><td width="$width%" valign="top"><dir>\n|;
}
$i = 0;
my $cat_db = $DB->table('Category');
foreach $cat_r (@$subcat) {
# Get the URL and the Category name.
$category_url = $CFG->{build_root_url} . "/" . $cat_db->as_url ($cat_r->{Full_Name}) . "/" . $CFG->{build_index};
($cat_r->{Name} =~ m,.*/([^/]+)$,) ? ($category_name = $1) : ($category_name = $cat_r->{Name});
$cat_r->{Short_Name} = $category_name;
$cat_r->{URL} = $category_url;
# Append @ if we are using Yahoo style cats, and it is related.
if ($cat_r->{Related}) {
if ($cat_r->{RelationName}) {
$cat_r->{Short_Name} = $cat_r->{RelationName};
}
else {
if (exists $parent_cat->{Name} and ($cat_r->{Short_Name} eq $parent_cat->{Name})) {
my ($short) = $cat_r->{Full_Name} =~ m,([^/]+)/[^/]*$,;
$short and ($cat_r->{Short_Name} = $short);
}
else {
$cat_r->{Short_Name} = $cat_r->{Short_Name};
}
}
}
# We check to see if we are half way through, if so we stop this table cell
# and begin a new one (this lets us have category names in two columns).
if ($CFG->{build_category_columns}) {
($i > 0) and !($i % $breakpoint) and ($cattable .= qq|</dir></td>\n<td valign="top" width="$width%"><dir>\n|);
$i++;
}
if ($cat_r->{Alphabar} eq 'Yes') {
$alphatable .= Links::load_template ('alphabar.html', $cat_r, 0);
}
else {
$cattable .= Links::load_template ('subcategory.html', $cat_r, 0);
} }
# Don't forget to end the unordered list..
if ($CFG->{build_category_columns}) {
$cattable .= "</dir></td></tr></table>\n";
}
chop $alphatable;
$alphatable .= "</td></tr></table>
\n";
$output = $alphatable;
$output .= $cattable; return $output;
}
---------------------------------------
Since the forums can sometimes alter the appearance of the code, I've also placed this section as a .txt file on my server for download and copying:
http://www.qango.com/.../alphabar_beta_1.txt If you do manage to solve some of the remaining issues with this mod, or indeed get it ported to a plugin, I'd love to see the results
All the best
Shaun