This is really curious as I did post something.
Any way here is it:
This global is great: it allows me to display on the front page the latest xx links. However, there is a problem when a link belongs to several categories: it appears duplicated. For example, if a link belongs to 3 categories, the global will diplay it 3 times.
So what should I add so no matter how much categories a links belongs to, it will be displayed only once ?
Thanks in advance,
Brakkar
# Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 30');
my $cats = [35,42];
my $cond = GT::SQL::Condition->new( 'CategoryID','IN', $cats); $cond->not; my $cond2 = GT::SQL::Condition->new($cond, 'isValidated','=','Yes'); $sth = $search_db->select ( $cond2 ); my $x = 0; while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
Links::init_date();
$link->{Add_Date} = GT::Date::date_transform ($link->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
if ($x < 15) {
$output .= Links::SiteHTML::display('linkfront', $link);
}
else {
$output .= Links::SiteHTML::display('linkfront', $link);
}
$x++;
}
return $output;
}
Any way here is it:
This global is great: it allows me to display on the front page the latest xx links. However, there is a problem when a link belongs to several categories: it appears duplicated. For example, if a link belongs to 3 categories, the global will diplay it 3 times.
So what should I add so no matter how much categories a links belongs to, it will be displayed only once ?
Thanks in advance,
Brakkar
Quote:
sub { # Displays the newest links on the home page.
my ($output,$sth,$link);
my $search_db = $DB->table('Links','CatLinks');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 30');
my $cats = [35,42];
my $cond = GT::SQL::Condition->new( 'CategoryID','IN', $cats); $cond->not; my $cond2 = GT::SQL::Condition->new($cond, 'isValidated','=','Yes'); $sth = $search_db->select ( $cond2 ); my $x = 0; while ($link = $sth->fetchrow_hashref) {
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
Links::init_date();
$link->{Add_Date} = GT::Date::date_transform ($link->{Add_Date}, $CFG->{date_db_format}, $CFG->{date_user_format});
if ($x < 15) {
$output .= Links::SiteHTML::display('linkfront', $link);
}
else {
$output .= Links::SiteHTML::display('linkfront', $link);
}
$x++;
}
return $output;
}