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

Fix for Days_Old plugin running under Links 3.0.3 ?

Quote Reply
Fix for Days_Old plugin running under Links 3.0.3 ?
Hi All!

I just recently upgraded from Links SQL 2.2.1 => 3.0.3 without many major problems. The only thing I'm still having a issue with is the Days_Old plugin. After the upgrade it's no longer working. I've played with the code, searched the forums, and had no luck.

Anyone ran into the same problem? Know of a fix and/or have and clue as to what might be wrong?

Thanks for any help!


Code Snip:

package Plugins::Days_Old;
# ==================================================================
use strict;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$IN $DB $TPL/;
use GT::Date;

sub link {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'site_html_link'
# is run. You should return STOP if you don't want
# the regular code to run, or CONTINUE if you want
# the regular code to run.
#
my $link = shift;

# added line to preserve Add_Date from Links table row
$link->{Add_Date1} = $link->{Add_Date} ;

# Links Days_Old calculate
# Figure out how many days old it is if it's a new link.

if ($link->{'isNew'} eq 'Yes') {
$link->{'Days_Old'} = GT::Date::date_diff ( GT::Date::date_get(), $link->{'Add_Date1'});
}
else {
$link->{'Days_Old'} = '';
}
return $link;
}


sub subcategory {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'site_html_print_cat'
# is run. You should return STOP if you don't want
# the regular code to run, or CONTINUE if you want
# the regular code to run.
#

my $subcat = shift;
my $cat_db = $DB->table('Category');

for (my $x=0;$x<scalar(@$subcat);$x++) {
my $cat_r=$subcat->[$x];

# Calculate the number of days old.
if ($cat_r->{'Has_New_Links'}) {
$cat_r->{'Days_Old'} = GT::Date::date_diff (GT::Date::date_get(), $cat_r->{'Newest_Link'});
}
else { $cat_r->{'Days_Old'} = ''; }

}
return $subcat;
}
Quote Reply
Re: [Jonze] Fix for Days_Old plugin running under Links 3.0.3 ? In reply to
Hi,

Is there any need for a plugin? :/

Something like this *should* return a days value;

<%set TmpDate = GT::Date::date_get()%>
<%GT::Date::date_diff($TmpDate, $Add_Date1)%>

Hope that helps :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Fix for Days_Old plugin running under Links 3.0.3 ? In reply to
Long time no speak Andy! Thanks for the help...Smile

Yes, that does look like it should work fine when using in a template like "link.html". The problem is I'm trying to calulate the "days old" for use in templates like subcategories.html to display category icons similar to those at hotscripts.com . Like so..

<%set TmpDate = GT::Date::date_get()%>
<%set Old_Days = GT::Date::date_diff($TmpDate, $Newest_Link)%>
<%if isValidated eq 'Yes' and Old_Days < 3%>
<img src="<%build_images_url%>/graphics/cats-folder3.gif" alt="<%Short_Name%>" border=0 width="20" height="17">
<%elseif%>
and so on...

The "Newest_Link" doesn't seem to be available. I can't figure out why, because it looks like it should be availble. Is there an easy way to pull date like Newest_Link from the Category table???

Thanks for any additional help on this.
Quote Reply
Re: [Andy] Fix for Days_Old plugin running under Links 3.0.3 ? In reply to
Just a quick update concerning my last post...

I just ran another <%GT::Template::dump%> ( on the correct template this time Crazy ), and found the "Newest_Link" is available in the subcategories.html template. Now if I could only figure out why the code I posted above isn't working.

I'm still very open for any tips or suggestions. Thanks
Quote Reply
Re: [Andy] Fix for Days_Old plugin running under Links 3.0.3 ? In reply to
Wow, looks like I finally found the problem...

I guess something must have been changed in Links3 which makes the ( isValidate eq 'Yes' ) no longer valid. Without that everthing is now working great.

So there you have it. Andy was on top of things as always, and sent the Days_Old plugin the way of the dinosaurs. Thanks again Andy!

Now to find the correct way to format ( isValidated eq 'Yes' )

Laterz
Quote Reply
Re: [Jonze] Fix for Days_Old plugin running under Links 3.0.3 ? In reply to
Hi,

Search for the updated Days_Old plugin. I modified a few years back, and it has some "fixes" for the various problems, but I think it has some code that answers your questions. Probably just search for Days_Old and my username.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Fix for Days_Old plugin running under Links 3.0.3 ? In reply to
Thanks PugDog Smile