Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

Days_Old "plugin" hack

Quote Reply
Days_Old "plugin" hack
I've got a crude, but working version of the Perl Days_Old plugin working for using a graphic to represent new links. (As an aside, I've always wondered why this isn't built into Links as a standard feature, since it seems to be quite popular and a natural extension of the "new" superscript titles.)

I haven't done it yet for categories, just links at this point, but it should be pretty similar. In Utils.inc.php, function _print_link(), I added the following just after if (!isset($opts['return_as_string'])) at the top (before the function makes display preference adjustments to some of the necessary values:

Code:
if ($link['isNew'] == 'Yes') {
$add_date = explode("-", $link['Add_Date']);
$add_stamp = mktime(12, 0, 0, $add_date[1], $add_date[2], $add_date[0]);
$today_stamp = mktime(12, 0, 0, date("m, d, Y"));
$link['Days_Old'] = ($today_stamp - $add_stamp) / (24*60*60);
} else {
$link['Days_Old'] = '';
}

Then in link.html, you can use $Days_Old to represent the number of days old a link is, such as to assign a graphic to it corresponding to the number. For example:

Code:
<?if ($isNew) {?>
<img src="/images/new<?echo $Days_Old?>.gif">
<?}?>

It looks like a similar treatment to function _print_cat() right below it will handle the categories, but I haven't yet tested that.

There aren't any built in functions for the PHP front end like GT::Date::date_diff (sub date_diff{} in Date.pm), are there?

Dan
Subject Author Views Date
Thread Days_Old "plugin" hack Dan Kaplan 4120 Jul 10, 2002, 4:25 PM
Thread Re: [Dan Kaplan] Days_Old "plugin" hack
Dan Kaplan 4034 Jul 10, 2002, 4:53 PM
Thread Re: [Dan Kaplan] Days_Old "plugin" hack
Dan Kaplan 4030 Jul 10, 2002, 5:22 PM
Post Re: [Dan Kaplan] Days_Old "plugin" hack
Dan Kaplan 4005 Jul 10, 2002, 9:12 PM