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:
# -------------------------------------------------------------------
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:
$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
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;
}
<%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 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