is there a global to display the recent isNew links and also the isChanged links together?
Jan 11, 2003, 4:30 PM
User (277 posts)
Jan 11, 2003, 4:30 PM
Post #2 of 18
Views: 4366
So can someone help if i add {isChanged => 'Yes'} to the code, it'll only look for links with both isNew and isChanged, but how can i display the latest isNew and isChanged links?
my $sth = $db->select ( { isNew => 'Yes'},{isChanged => 'Yes'},{ isValidated => 'Yes'} );
my $sth = $db->select ( { isNew => 'Yes'},{isChanged => 'Yes'},{ isValidated => 'Yes'} );
Jan 11, 2003, 5:14 PM
Veteran (19537 posts)
Jan 11, 2003, 5:14 PM
Post #5 of 18
Views: 4259
Quote:
if i add {isChanged => 'Yes'} to the code, it'll only look for links with both isNew and isChanged, but how can i display the latest isNew and isChanged links?No it won't, it will display links with isChanged = Yes
Quote:
That will still look for links with both isNew and isChanged equal yes!It sounded like that was what you were asking for in your OP....
>>
but how can i display the latest isNew and isChanged links?
<<
If not, can you explain more to make things clearer?
Jan 12, 2003, 5:38 AM
Veteran (19537 posts)
Jan 12, 2003, 5:38 AM
Post #9 of 18
Views: 4243
Code:
sub { my $output;
my $tab = $DB->table('Links');
$tab->select_options('ORDER BY Title ASC', 'LIMIT 10');
require Links::SiteHTML;
my $sth = $tab->select({ isNew => 'Yes', isChanged => 'Yes', isValidated => 'Yes' });
while (my ($rec) = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $rec);
}
$sth->finish;
return $output;
}
Jan 12, 2003, 9:18 AM
Veteran (1921 posts)
Jan 12, 2003, 9:18 AM
Post #11 of 18
Views: 4250
You need a condition statement with OR. If you click on help in your admin and then GT Module Documentation you should see 'Condition' down the left side of the page (under SQL). This tells you how to use it. Also search the forum for condition and you should get some examples.
Laura.
The UK High Street
Laura.
The UK High Street
Jan 12, 2003, 10:03 AM
User (277 posts)
Jan 12, 2003, 10:03 AM
Post #16 of 18
Views: 4227
Hey Laura, I got it working to the point where it would display isNew or isChanged link, but however i can't seem to get the ORDER BY condition to work with ADD_DATE and MOD_DATE, right now it sorts that all isNew first and isChanged last!
sub {
# Displays New links by category.
my ($output,$sth,$link);
require GT::SQL::Condition;
my $id = shift;
my $db = $DB->table ('Links','CatLinks');
$db->select_options ('ORDER BY ADD_DATE DESC', 'LIMIT 10');
my $cond = GT::SQL::Condition->new (
'isNew', '=', 'Yes',
'isChanged', '=', 'Yes'
);
$cond->bool ('OR') ;
my $sth = $db->select ($cond, { isValidated => 'Yes' });
my $premium;
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('newlinks', $link);
}
return $output;
}
sub {
# Displays New links by category.
my ($output,$sth,$link);
require GT::SQL::Condition;
my $id = shift;
my $db = $DB->table ('Links','CatLinks');
$db->select_options ('ORDER BY ADD_DATE DESC', 'LIMIT 10');
my $cond = GT::SQL::Condition->new (
'isNew', '=', 'Yes',
'isChanged', '=', 'Yes'
);
$cond->bool ('OR') ;
my $sth = $db->select ($cond, { isValidated => 'Yes' });
my $premium;
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('newlinks', $link);
}
return $output;
}
Jan 12, 2003, 10:20 AM
Veteran (1921 posts)
Jan 12, 2003, 10:20 AM
Post #17 of 18
Views: 4217
If you use Mod_Date instead of Add_Date - doesn't that do what you want? The Mod_Date will be the same as Add_Date for new links so I think this should work.
The UK High Street
The UK High Street