Gossamer Forum
Quote Reply
Category List
I am trying to build a 3 coloumn list of all categories listed alphabetically. I was building my categories by ID and the following global worked fine, I am now building based on categories and need some help with the output....

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","sm_graphic"] );

my $cols = 3;
my $row_count = $sth->rows;
my $breakpoint = int (($row_count) / $cols) + ( (($row_count) % $cols) ? 1 : 0);
my $width = int (100 / $cols);
my $output = qq|<table width="100%" border=0><tr><td width="$width%" valign="top"><tr><td valign="top">\n|;

while ($row = $sth->fetchrow_hashref) {
$letter = uc(substr($row->{Name}, 0, 1));
if ($letter !~ /$oldletter/i ){
$output .= qq|<P><font face="Arial"><b><a name="$letter">$letter</a></b></font></P>\n|;
$oldletter = $letter;
}
$output .= qq|<font face="Arial" size="2"><a href="$CFG->{build_root_url}/$row->{ID}">$row->{Name}</a></font><br>\n|;
($i > 0) and !($i % $breakpoint) and ($output .= qq|</td>\n<td valign="top" width="$width%">\n|);
$i++;
}
$output .= "</td></tr></table></font>\n";
return $output;
}


Thanks....
George
Subject Author Views Date
Thread Category List macbethgr 3893 Sep 4, 2004, 1:25 PM
Thread Re: [macbethgr] Category List
jdgamble 3784 Sep 6, 2004, 1:10 PM
Post Re: [jdgamble] Category List
macbethgr 3751 Sep 6, 2004, 5:07 PM
Thread Re: [macbethgr] Category List
jdgamble 3759 Sep 6, 2004, 6:38 PM
Thread Re: [jdgamble] Category List
macbethgr 3747 Sep 7, 2004, 2:16 AM
Thread Re: [macbethgr] Category List
jdgamble 3721 Sep 7, 2004, 10:41 AM
Thread Re: [jdgamble] Category List
macbethgr 3718 Sep 7, 2004, 10:51 AM
Thread Re: [macbethgr] Category List
jdgamble 3731 Sep 7, 2004, 1:58 PM
Thread Re: [jdgamble] Category List
macbethgr 3730 Sep 7, 2004, 6:36 PM
Post Re: [macbethgr] Category List
jdgamble 3719 Sep 8, 2004, 4:51 PM