Gossamer Forum
Quote Reply
christmas favor:)
I'm trying to use the days old plugin from a template used for a global name last_links, but however it does not work.

I tried to copy the sub from the days_old plugin and use it as a global, but however the global return nothing.. can someone help me?



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;

}

Quote Reply
Re: [xpert] christmas favor:) In reply to
Maybe its just too early in the morning, but I can't quite understand what you are asking Unsure

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: [xpert] christmas favor:) In reply to
$link is a hashref and in order to get it to work as a global you'd have to pass in a hashref, however you can't do this with the template parser.

You'll need to pass in the link ID and then select the link record from within the global.
Quote Reply
Re: [Paul] christmas favor:) In reply to
Thx for help unfortunately i still can't get it to work!
Quote Reply
Re: [xpert] christmas favor:) In reply to
Can anyone help, quite important!
Quote Reply
Re: [xpert] christmas favor:) In reply to
Mm it's kinda boxing day and you waited 4 hours before following up your post?
Quote Reply
Re: [Paul] christmas favor:) In reply to
hehe! sigh.
Quote Reply
Re: [xpert] christmas favor:) In reply to
So can anyone please help work this out? thank you!
Quote Reply
Re: [xpert] christmas favor:) In reply to
I tried to use the following tag in the template

<%GT::Date::date_diff (GT::Date::date_get(),$Add_Date)%>

But however it returns un rare number like -12044

Any ideas why?
Quote Reply
Re: [xpert] christmas favor:) In reply to
You have to set the input format first. Check the GT::Date docs for more info how to do that.
Then later set back to original format.

You would better write a global for that task. Not a big deal, tough.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [xpert] christmas favor:) In reply to
Hi,

Is this my updated date routines?

I'm pretty sure I have my days_old working with the current version of Links.

It's not a plug in, you just copy the subroutines to another file and call them in your template. I posted them to the forum awhile back (6 months+ maybe).

It addressed the date format problems, and possibly even had some comments on how to deal with it in your own programs. you can pass in a couple of parameters to change the output.

I'm gathering all my code snips to gether, and will have a single plugin Widget release that gathers them all in one place, and will let you add to it (hopefully from a simple admin interface).


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] christmas favor:) In reply to
Hey Pugdog,

I found your code in a search, added it to the utils.pm, unfortunately the tag return nothing when called from my newlinks.html template!
Quote Reply
Re: [xpert] christmas favor:) In reply to
Hi,

How are you calling it?


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] christmas favor:) In reply to
the tag

<%Links::Utils::link_Days_Old%>

Quote Reply
Re: [xpert] christmas favor:) In reply to
And you have it in the link.html?

Try calling it with a parameter

<%Links::Utils::link_Days_Old(10,0)%>

(this won't mess up your process).

Make sure it's not returning an error.

Also, put <%GT::Template::dump%> at the bottom of the link.html, maybe surround it with:

<%if Username=admin%><%GT::Template::dump%><%endif%>


Log in as admin, and check to see that there is a value in the returned hash. "stage_one" should have a message in it, as part of the debugging code if you copied it fully.

NOTE: This doesn't reset the category stuff, there is a second routine that does that.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] christmas favor:) In reply to
i'm calling the tag from newlinks.html template resulted from a newest link global!
Quote Reply
Re: [xpert] christmas favor:) In reply to
And here's the new links global i'm using...

sub {

# Displays New links by category.

my ($output,$sth,$link);

my $id = shift;

my $db = $DB->table ('Links','CatLinks');

$db->select_options ('ORDER BY ADD_DATE DESC', 'LIMIT 10');

my $sth = $db->select ( { isNew => 'Yes'},{ isValidated => 'Yes'} );

my $premium;

while ($link = $sth->fetchrow_hashref) {

$output .= Links::SiteHTML::display ('newlinks', $link);

}

return $output;

}