Hi,
The easiest way, would be to make a new .cgi script - say "update_reviews.cgi" in the admin folder, with the following:
use strict;
use lib '/path/to/admin';
use Links qw/$DB $IN $USER $CFG/;
use GT::Mail;
use CGI::Carp qw(fatalsToBrowser);
use Links::Plugins;
use Links;
Links::init('/path/to/admin');
my $sth = $DB->table('Links')->select( ['ID'] ) || die $GT::SQL::error;
while (my $id = $sth->fetchrow) {
my $cnt = $DB->table('Reviews')->count( { Review_LinkID => $id } ) || 0;
$DB->table('Links')->update( { ReviewCount => $cnt }, { ID => $id } ) || die $GT::SQL::error;
print qq|Updated linkID $id with $cnt reviews \n|;
}
Then, setup a cronjob to run each day.
perl /path/to/admin/update_reviews.cgi
Then, be sure to add a new field in the "Links" table via:
Database > Links > Properties > Add Column.
Name: ReviewCount
Type: INT
Then, run this script manually (via SSH), and check to see if the links have had their new ReviewCount field updated correctly.
Then, this global should grab the results you want:
# Displays 20 random links with no review
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY RAND()', 'LIMIT 20');
$sth = $search_db->select ( { isValidated => 'Yes', ReviewCount => '0' } );
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 26) {
$link->{Titleshort} = substr($link->{Title}, 0, 25) . '...';
}
$output .= Links::SiteHTML::display ('templatename', $link);
}
return $output;
}
Hope that helps :)
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
The easiest way, would be to make a new .cgi script - say "update_reviews.cgi" in the admin folder, with the following:
Code:
#!/usr/local/bin/perl use strict;
use lib '/path/to/admin';
use Links qw/$DB $IN $USER $CFG/;
use GT::Mail;
use CGI::Carp qw(fatalsToBrowser);
use Links::Plugins;
use Links;
Links::init('/path/to/admin');
my $sth = $DB->table('Links')->select( ['ID'] ) || die $GT::SQL::error;
while (my $id = $sth->fetchrow) {
my $cnt = $DB->table('Reviews')->count( { Review_LinkID => $id } ) || 0;
$DB->table('Links')->update( { ReviewCount => $cnt }, { ID => $id } ) || die $GT::SQL::error;
print qq|Updated linkID $id with $cnt reviews \n|;
}
Then, setup a cronjob to run each day.
perl /path/to/admin/update_reviews.cgi
Then, be sure to add a new field in the "Links" table via:
Database > Links > Properties > Add Column.
Name: ReviewCount
Type: INT
Then, run this script manually (via SSH), and check to see if the links have had their new ReviewCount field updated correctly.
Then, this global should grab the results you want:
Code:
sub { # Displays 20 random links with no review
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY RAND()', 'LIMIT 20');
$sth = $search_db->select ( { isValidated => 'Yes', ReviewCount => '0' } );
while ($link = $sth->fetchrow_hashref) {
if (length $link->{Title} > 26) {
$link->{Titleshort} = substr($link->{Title}, 0, 25) . '...';
}
$output .= Links::SiteHTML::display ('templatename', $link);
}
return $output;
}
Hope that helps :)
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!