I did put together a small piece of code. I hope it will work.
I had no time to try it out, so there may syntax error in it, but the main logic should be good. If not it should be a good base to start.
my ($db, $sth, $row, $oldletter, $letter, $i);
my $output="";
$db = $DB->table('Category');
$db->select_options("ORDER BY Name");
$sth = $db->select( ['ID','Name'] );
my $cols = 3;
my $row_count = $sth->hits;
my $breakpoint = int (($row_count) / $cols) + ( (($row_count) % $cols) ? 1 : 0);
my $width = int (100 / $cols);
my $table = qq|<table><tr><td width="$width%" valign="top">\n|;
while ($row = $sth->fetchrow_hashref) {
$letter = substr($row->{Name}, 0, 1);
if ($letter ne $oldletter){
$output .= qq|<b>$letter</b><br>\n|;
$oldletter = $letter;
}
$output .= qq|<br><a href="$CFG->{build_root_url}/$row->{ID}">$row->{Name}</a>\n|;
($i > 0) and
!($i % $breakpoint) and
($output .= qq|</td>\n<td valign="top" width="$width%">\n|);
$i++;
}
$output .= "</td></tr></table>\n";
return $output;
}
The link count is missing from the generated list, but this is an easy task, even you can do it. If not, others will help you.
Good luck!
BTW: let me know how it worked.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
I had no time to try it out, so there may syntax error in it, but the main logic should be good. If not it should be a good base to start.
Code:
sub { my ($db, $sth, $row, $oldletter, $letter, $i);
my $output="";
$db = $DB->table('Category');
$db->select_options("ORDER BY Name");
$sth = $db->select( ['ID','Name'] );
my $cols = 3;
my $row_count = $sth->hits;
my $breakpoint = int (($row_count) / $cols) + ( (($row_count) % $cols) ? 1 : 0);
my $width = int (100 / $cols);
my $table = qq|<table><tr><td width="$width%" valign="top">\n|;
while ($row = $sth->fetchrow_hashref) {
$letter = substr($row->{Name}, 0, 1);
if ($letter ne $oldletter){
$output .= qq|<b>$letter</b><br>\n|;
$oldletter = $letter;
}
$output .= qq|<br><a href="$CFG->{build_root_url}/$row->{ID}">$row->{Name}</a>\n|;
($i > 0) and
!($i % $breakpoint) and
($output .= qq|</td>\n<td valign="top" width="$width%">\n|);
$i++;
}
$output .= "</td></tr></table>\n";
return $output;
}
The link count is missing from the generated list, but this is an easy task, even you can do it. If not, others will help you.
Good luck!
BTW: let me know how it worked.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...