Hi!
Below you'll find two (I hope in this case: relevant) parts of sub "site_html_print_cat" from my SiteHTML.pm. Because I'm not a Perl-Guru like some of you are I'll need your advice for the following changes I'd like to do.
My goal is to change "build_category_columns" and set it to "X" (I'm not yet sure about the number) automatically if there's a category that contains (any number of) subcategories with 2 or less than 2 chars only (what I mean is: every subcategory has to have 2 or less than 2 chars; if there's just one with more than 2 chars there should be no changes). E.G. if there's:
SomeCategory
... with SubCategories named like:
0
a
0a
a0
00
aa
... I want X colums instead of the number of colums I defined in "Setup".
I think there's some "$columns" (or "my $columns" ?) needed to replace "$CFG->{build_category_columns})" ... but I have no idea how and where to write the "if then"-thing to get this new "$columns" that could replace $CFG->{build_category_columns})"!? :-/
sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_columns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
my $output = '';
my $i = 0;
my $cat_db = $DB->table('Category');
my $opts = { dynamic => 0 };
...
# 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 ($output .= qq| ...
Below you'll find two (I hope in this case: relevant) parts of sub "site_html_print_cat" from my SiteHTML.pm. Because I'm not a Perl-Guru like some of you are I'll need your advice for the following changes I'd like to do.
My goal is to change "build_category_columns" and set it to "X" (I'm not yet sure about the number) automatically if there's a category that contains (any number of) subcategories with 2 or less than 2 chars only (what I mean is: every subcategory has to have 2 or less than 2 chars; if there's just one with more than 2 chars there should be no changes). E.G. if there's:
SomeCategory
... with SubCategories named like:
0
a
0a
a0
00
aa
... I want X colums instead of the number of colums I defined in "Setup".
I think there's some "$columns" (or "my $columns" ?) needed to replace "$CFG->{build_category_columns})" ... but I have no idea how and where to write the "if then"-thing to get this new "$columns" that could replace $CFG->{build_category_columns})"!? :-/
sub site_html_print_cat {
# --------------------------------------------------------
# This routine prints out a list of categories.
#
my $subcat = shift;
my $parent_cat = shift @$subcat;
my $breakpoint = int (($#{$subcat}+1) / $CFG->{build_category_columns}) + ( (($#{$subcat}+1) % $CFG->{build_category_columns}) ? 1 : 0);
my $table_head = $CFG->{build_category_table} || '';
my $width = int (100 / $CFG->{build_category_columns});
my $output = '';
my $i = 0;
my $cat_db = $DB->table('Category');
my $opts = { dynamic => 0 };
...
# 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 ($output .= qq| ...