Gossamer Forum
Home : Products : Gossamer Links : Discussions :

3 Column Links: Stand alone

Quote Reply
3 Column Links: Stand alone

I try to make 3 column links with the script below but it was not align as i need, what i need is the script will print out 3x3x3 but what was happen is the script was print 4x3x2:


my $txtfile = '/home/username/public_html/links/lastlinkstxt.txt';

use strict;
#use lib '/home/username/public_html/links/cgi-bin/admin';
use lib '/home/username/public_html/links/cgi-bin/admin';
use Links qw/$DB $CFG/;
Links::init ('/home/username/public_html/links/cgi-bin/admin'); # Required
#Links::init ('/home/gossamer/lsqldev-2.1.0/admin'); # Required

use Links::SiteHTML;

local $SIG{__DIE__} = \&Links::fatal;


sub main {
# Display the newest link.

my $cat_db = $DB->table('Category');
my ($all_ids,@list);
my $cat_id = '226';
$all_ids = $DB->table('Category')->children($cat_id);
push @$all_ids, $cat_id;
my $link_db = $DB->table('Links','CatLinks','Category');
$link_db->select_options ("ORDER BY Add_Date DESC LIMIT 9");
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', \@$all_ids);
my $sth = $link_db->select($condition);
my $list = $cat_db->count($condition);
my $breakpoint = int (($list+1)/2) + ( (($list+1) % 2) ? 1 : 0);
my $i=1;
while (my $rec = $sth->fetchrow_hashref) {
push @list, $rec;

my $output;
my $output = "<table width=100%><tr><td align=center>";
foreach my $rec (@list) {
# Set the category url
my $url = $DB->table('Category')->as_url($rec->{'Full_Name'});
# Set the detailed_url
my $detailed_url = "$CFG->{build_detail_url}/$rec->{'LinkID'}$CFG->{build_extension}";
($i > 0) and !($i % $breakpoint) and ($output .= qq~~);
$output .= Links::SiteHTML::display('lastlinktxt', $rec);
$output .= qq~</td>~;
if ($i==3 or $i==6 or $i==9){
$output .= qq~</tr><tr><td align=center>~;
$output .= qq~<td align=center>~;
$output .= qq~</td></tr></table>~;
open (LASTLINKS, ">$txtfile") or die("Unable to open textfile: $txtfile Reason: $!");
print LASTLINKS $output;
return $output;

Please help.

Last edited by:

reenee: May 25, 2003, 7:02 AM
Quote Reply
Re: [reenee] 3 Column Links: Stand alone In reply to
Try changing $i=1 to $i=0 and see what that does.
Quote Reply
Re: [afinlr] 3 Column Links: Stand alone In reply to
Yes, Its work now, Thank you so much afinlr