Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

How to sort date in my global?

Quote Reply
How to sort date in my global?
Hi,

I need your help.
I have following global.
I would like to sort $output by $link->{'Mod_Date'} .

# globals

sub {
my $tags = shift;
my $x =100;
my $table = $DB->table('Links');
$table->select_options ('ORDER BY Hits DESC', "LIMIT $x");
my $sth = $table->select({ isNewinfo => 'Yes',isValidated => 'Yes'});
my $output;
while (my $link = $sth->fetchrow_hashref) {
$link->{'Mod_Date'} = GT::Date::date_transform($link->{'Mod_Date'},"%yyyy%-%mm%-%dd%", "%mm% %dd%");

my $atitle = $link->{'Title'};
my $anewinfo = $link->{'New_info'};
my $var = $link->{'Title'}.= $link->{'New_info'};

if(length $var > 80){

my $short = substr($var,0,80);
my $len1 = length $atitle;
my $short2 = substr($short,$len1);

$output.= qq|$link->{'Mod_Date'}&nbsp;<a href="">$atitle</a>&nbsp;$short2<br>|;

}
else{
$output.= qq|$link->{'Mod_Date'}&nbsp;<a href="">$atitle</a>&nbsp;$anewinfo<br>|;
}

}
return $output;
}

# end global

Thank you,

Best regards from
Far East
Quote Reply
Re: [motoman] How to sort date in my global? In reply to
Hi,

worked out!

just added "Mod_date DESC" at select_options.Frown

Thanks