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

Re: Days Old Plug In works okay?

Quote Reply
Re: Days Old Plug In works okay? In reply to
Ok,

I seem to have gotten it working. The problem is more the date format than anything else. You need to make sure that the date is returned from GT::Date::date_get() in the format the other dates are being returned in.

That means, you might need to specify:

GT::Date::date_set_format('%ddd% %mmm% %dd% %yyyy%');

or some other format, depending on where you are calling the date. Remember, Add_Date is stored as "yyyy-mm-dd" internally, but it's output as "Thu Jul 12 2001" in the templates.

So, the routine becomes:

Code:
sub link {
# -------------------------------------------------------------------
my $link = shift;
Links::init_date(); ## you can either 'use GT::Date' or do it this way, this is probably better
GT::Date::date_set_format('%ddd% %mmm% %dd% %yyyy%'); ## this is the key to making it work
if (($link->{'isNew'} eq 'Yes') or ($link->{'isNew'} == 1)){
$link->{'Days_Old'} = GT::Date::date_diff ( GT::Date::date_get(), $link->{'Add_Date'});
}
else {
$link->{'Days_Old'} = '';
}
return $link;
}
I've actually just added this to the top of the link.html as a call to:

<%Plugins::Days_Old::link%>

and disabled all the hooks.

You can do something similar for the categories if you wish.

As for broken images, I sort of have a fix for that too.

If you only have 14 different graphics, (or whatever number), create a graphic that is only 1x1 pixels, or is transparent, etc. Give it a name in your series, like new_99.gif.

Change the first test in the above routine to be:

Code:
if (($link->{'isNew'} eq 'Yes') or ($link->{'isNew'} == 1)){
$link->{'Days_Old'} = GT::Date::date_diff ( GT::Date::date_get(), $link->{'Add_Date'});
($link->{'Days_Old'} <= 14) or ($link->{'Days_Old'} = 99);
}
If the link is older than your largest graphic file (14 days) it will call the new_99.gif file, which will be invisible to the user, but will prevent a broken image.

If you wanted to be slick, you could make it a call to $CFG->{'build_new_cutoff'}, but that would mean adding $CFG to the use Links line at the top of the file, and would impose some additional overhead for something so trivial.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Subject Author Views Date
Thread Days Old Plug In works okay? Pitman 6772 Apr 19, 2001, 10:44 AM
Thread Re: Days Old Plug In works okay?
katabd 6722 Apr 19, 2001, 11:34 AM
Thread Re: Days Old Plug In works okay?
Pitman 6696 Apr 19, 2001, 12:17 PM
Thread Re: Days Old Plug In works okay?
Clint 6619 Apr 19, 2001, 10:37 PM
Thread Re: Days Old Plug In works okay?
pugdog 6645 Apr 19, 2001, 11:43 PM
Thread Re: Days Old Plug In works okay?
Pitman 6600 Apr 21, 2001, 8:24 AM
Thread Re: Days Old Plug In works okay?
Robert_B 6619 Jul 11, 2001, 6:56 AM
Thread Re: Days Old Plug In works okay?
pugdog 6590 Jul 11, 2001, 12:10 PM
Thread Re: Days Old Plug In works okay?
pugdog 6565 Jul 12, 2001, 8:19 AM
Thread Re: Days Old Plug In works okay?
pugdog 6571 Jul 14, 2001, 2:40 AM
Thread Re: Days Old Plug In works okay?
Pitman 6563 Jul 14, 2001, 4:40 PM
Post Re: Days Old Plug In works okay?
pugdog 6566 Jul 14, 2001, 8:08 PM
Thread Re: Days Old Plug In works okay?
pugdog 6522 Jul 16, 2001, 1:20 AM
Thread Re: [pugdog] Days Old Plug In works okay?
pugdog 6329 Jan 1, 2002, 6:58 PM
Post Re: [pugdog] Days Old Plug In works okay?
pugdog 6315 Jan 2, 2002, 6:30 AM