Gossamer Forum
Home : Products : Gossamer Links : Discussions :

recent links global

Quote Reply
recent links global
is there a global to display the recent isNew links and also the isChanged links together?
Quote Reply
Re: [xpert] recent links global In reply to
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'} );
Quote Reply
Re: [xpert] recent links global In reply to
Try with:

my $sth = $db->select ({ isNew => 'Yes', isChanged => 'Yes', isValidated => 'Yes' });
Quote Reply
Re: [Payooo] recent links global In reply to
That will still look for links with both isNew and isChanged equal yes!
Quote Reply
Re: [xpert] recent links global In reply to
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?

Last edited by:

Paul: Jan 11, 2003, 5:15 PM
Quote Reply
Re: [Paul] recent links global In reply to
Sorry if my question was confusing.. but i need latest links with either the isNew and isChanged eq to Yes..
Quote Reply
Re: [xpert] recent links global In reply to
Payooo's suggestion was correct in that case as long as you use select_options to order and limit what you want.

Last edited by:

Paul: Jan 12, 2003, 2:27 AM
Quote Reply
Re: [Paul] recent links global In reply to
Anyway you can show me how to use the selection option to do that Paul?
Quote Reply
Re: [xpert] recent links global In reply to
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;
}
Quote Reply
Re: [Paul] recent links global In reply to
Hey Paul, I tried that, I return any links!
Quote Reply
Re: [xpert] recent links global In reply to
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
Quote Reply
Re: [afinlr] recent links global In reply to
Just checked back my last post, i meant when i use Paul's code, it didn't return any links:!
Quote Reply
Re: [xpert] recent links global In reply to
Do you definitely have 10 links where isNew, isValidated and isChanged are all Yes?

I just checked over the code and I can't see any reason why it would fail.
Quote Reply
Re: [xpert] recent links global In reply to
That's because it is looking for links which are both new and changed - I don't think that new links are ever changed links as well. You need an OR condition if you want either new or changed.
Quote Reply
Re: [afinlr] recent links global In reply to
I want to display links with either isNew or isChanged so Laura was right. Looking the forum and docs to see how to use OR condition now, but seems pretty confusing!
Quote Reply
Re: [afinlr] recent links global In reply to
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;

}
Quote Reply
Re: [xpert] recent links global In reply to
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
Quote Reply
Re: [afinlr] recent links global In reply to
All worked out fine, thank you!