Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [macbethgr] Directory global (lists all categories)

Quote Reply
Re: [macbethgr] Directory global (lists all categories) In reply to
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.

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...

Last edited by:

webmaster33: Jul 23, 2002, 11:18 AM
Subject Author Views Date
Thread Directory global (lists all categories) macbethgr 8391 Jul 22, 2002, 6:32 AM
Thread Re: [macbethgr] Directory global (lists all categories)
, 8244 Jul 22, 2002, 6:58 AM
Thread Re: [tpl] Directory global (lists all categories)
, 8270 Jul 22, 2002, 7:01 AM
Post Re: [tpl] Directory global (lists all categories)
Paul 8220 Jul 22, 2002, 7:52 AM
Thread Re: [macbethgr] Directory global (lists all categories)
macbethgr 8208 Jul 23, 2002, 10:19 AM
Thread Re: [macbethgr] Directory global (lists all categories)
webmaster33 8202 Jul 23, 2002, 11:12 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8176 Jul 23, 2002, 11:33 AM
Thread Re: [macbethgr] Directory global (lists all categories)
Paul 8226 Jul 23, 2002, 11:43 AM
Thread Re: [Paul] Directory global (lists all categories)
webmaster33 8235 Jul 23, 2002, 11:46 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8218 Jul 24, 2002, 5:25 AM
Thread Re: [macbethgr] Directory global (lists all categories)
webmaster33 8143 Jul 24, 2002, 6:07 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8195 Jul 24, 2002, 6:15 AM
Post Re: [macbethgr] Directory global (lists all categories)
webmaster33 8113 Jul 24, 2002, 6:26 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8115 Jul 24, 2002, 6:45 AM
Post Re: [macbethgr] Directory global (lists all categories)
webmaster33 8078 Jul 24, 2002, 7:10 AM
Thread Re: [macbethgr] Directory global (lists all categories)
webmaster33 8100 Jul 24, 2002, 7:32 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8089 Jul 24, 2002, 9:01 AM
Post Re: [macbethgr] Directory global (lists all categories)
Paul 8166 Jul 24, 2002, 9:05 AM