OK, took a while to work out why it wasn't working - but found some errors in the globals (also, you're using an old version of LSQL [2.1], so had a few tag issues =))
The final codes are:
random_paid_in_category
my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ('ORDER BY RAND() DESC LIMIT 1');
my $time = time;
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
my $cond2 = GT::SQL::Condition->new('isValidated','=','Yes','ExpiryDate','>', $time, 'ExpiryDate', '<', 2147483647);
my $sth = $db_obj->select (['Links.*'], $cond, $cond2 ) || die $GT::SQL::error;
my @links;
while (my $hit = $sth->fetchrow_hashref) {
if ($CFG->{build_detailed}) { $hit->{detailed_url} = $CFG->{build_root_url} . "/Detailed/$hit->{ID}" }
if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }
push @links, $hit;
}
return { random_link => \@links }
}
check_if_paid_exists
my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $time = time;
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
my $cond2 = GT::SQL::Condition->new('isValidated','=','Yes','ExpiryDate','>', $time, 'ExpiryDate', '<', 2147483647);
# my $sth = $DB->table('Links','CatLinks','Category')->select ( $cond, $cond2 ) || die $GT::SQL::error;
# return $sth->query;
my $count = $DB->table('Links','CatLinks','Category')->count ( $cond, $cond2 ) || 0;
return { num_paid_found => $count }
}
..and the template code (category.html);
<%if num_paid_found > 0%>
<%random_paid_in_category($category_id)%>
<%if random_link.length%>
<%loop random_link%>
<%include include_paid_link.html%>
<%endloop%>
<%endif%>
<%endif%>
Tested, and its all working as its mean't to now :)
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
The final codes are:
random_paid_in_category
Code:
sub { my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ('ORDER BY RAND() DESC LIMIT 1');
my $time = time;
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
my $cond2 = GT::SQL::Condition->new('isValidated','=','Yes','ExpiryDate','>', $time, 'ExpiryDate', '<', 2147483647);
my $sth = $db_obj->select (['Links.*'], $cond, $cond2 ) || die $GT::SQL::error;
my @links;
while (my $hit = $sth->fetchrow_hashref) {
if ($CFG->{build_detailed}) { $hit->{detailed_url} = $CFG->{build_root_url} . "/Detailed/$hit->{ID}" }
if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }
push @links, $hit;
}
return { random_link => \@links }
}
check_if_paid_exists
Code:
sub { my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $time = time;
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
my $cond2 = GT::SQL::Condition->new('isValidated','=','Yes','ExpiryDate','>', $time, 'ExpiryDate', '<', 2147483647);
# my $sth = $DB->table('Links','CatLinks','Category')->select ( $cond, $cond2 ) || die $GT::SQL::error;
# return $sth->query;
my $count = $DB->table('Links','CatLinks','Category')->count ( $cond, $cond2 ) || 0;
return { num_paid_found => $count }
}
..and the template code (category.html);
Code:
<%check_if_paid_exists($category_id)%> <%if num_paid_found > 0%>
<%random_paid_in_category($category_id)%>
<%if random_link.length%>
<%loop random_link%>
<%include include_paid_link.html%>
<%endloop%>
<%endif%>
<%endif%>
Tested, and its all working as its mean't to now :)
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates



