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
This code do this:
- now the group letters are big
- both small and capital letters are listed in same group
- I did not corrected the bug, which causes not split into 3 columns
(I should execute the script to correct it. You have to correct this.)
- it is not possible so easily to merge the groups 0-9 into one. It is only possible if you do an exception, and you treat numbers separately.

Try this:
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->rows;
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 = uc(substr($row->{Name}, 0, 1));
if ($letter =~ /^$oldletter.*/i ){
$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;
}

You got the starting steps help, so I think you should finish yourself.
If you still have problems, post it here, and you may get the help.

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...
Subject Author Views Date
Thread Directory global (lists all categories) macbethgr 8390 Jul 22, 2002, 6:32 AM
Thread Re: [macbethgr] Directory global (lists all categories)
, 8242 Jul 22, 2002, 6:58 AM
Thread Re: [tpl] Directory global (lists all categories)
, 8269 Jul 22, 2002, 7:01 AM
Post Re: [tpl] Directory global (lists all categories)
Paul 8219 Jul 22, 2002, 7:52 AM
Thread Re: [macbethgr] Directory global (lists all categories)
macbethgr 8207 Jul 23, 2002, 10:19 AM
Thread Re: [macbethgr] Directory global (lists all categories)
webmaster33 8200 Jul 23, 2002, 11:12 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8175 Jul 23, 2002, 11:33 AM
Thread Re: [macbethgr] Directory global (lists all categories)
Paul 8225 Jul 23, 2002, 11:43 AM
Thread Re: [Paul] Directory global (lists all categories)
webmaster33 8234 Jul 23, 2002, 11:46 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8217 Jul 24, 2002, 5:25 AM
Thread Re: [macbethgr] Directory global (lists all categories)
webmaster33 8142 Jul 24, 2002, 6:07 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8194 Jul 24, 2002, 6:15 AM
Post Re: [macbethgr] Directory global (lists all categories)
webmaster33 8112 Jul 24, 2002, 6:26 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8114 Jul 24, 2002, 6:45 AM
Post Re: [macbethgr] Directory global (lists all categories)
webmaster33 8077 Jul 24, 2002, 7:10 AM
Thread Re: [macbethgr] Directory global (lists all categories)
webmaster33 8099 Jul 24, 2002, 7:32 AM
Thread Re: [webmaster33] Directory global (lists all categories)
macbethgr 8088 Jul 24, 2002, 9:01 AM
Post Re: [macbethgr] Directory global (lists all categories)
Paul 8165 Jul 24, 2002, 9:05 AM