Gossamer Forum
Home : Products : Links 2.0 : Customization :

How do you Compare a Date Field ?

Quote Reply
How do you Compare a Date Field ?
Hi,

I have added a field in links where i put a date when the link expires. I need to be able to check whether the expiry date is older than todays date and then display it has expired. Not all fields have an entry..

I have tried

<%if Expires > ''%>
<%if Date > Expires%>
EXPIRED
<%endif%>
<%endif%>

But this does'nt work, does anyone have any ideas ?

Thanks,

Matt
Quote Reply
Re: How do you Compare a Date Field ? In reply to
First of all, you would need the Enhanced Template.pm codes to be able to this type of comparison.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: How do you Compare a Date Field ? In reply to
Thanks AnthroRules, but I already have this added. The bit that checks for '' works.
Its the date comparison i am totally stuck on. Such as Expires = 12-Jan-2000 , and todays date is obviously later, so it would put up text to note this.

Any more ideas ?

Thanks
Quote Reply
Re: How do you Compare a Date Field ? In reply to
Yea...Try adding these codes at the top of your sub html_site_link in the site_html_templates.pl file:

Code:
my $days_old = &days_old($rec{'Date'});
my $expire = $rec{'Expires'};

You may have to use my $expire = &days_old($rec{'Expires'});...but give it shot.

Then add the following codes after these codes:

Code:
if ($days_old > $expire) {
$expiremessage = qq|Expired|;
}
else {
$expiremessage = qq|Not Expired|;
}

Then define the $expiremessage variable as a tag in the sub site_html_link routine:

Code:
expire => $expiremessage,

Then add the following tag in your link.html file:

Code:
<%expire%>

Hope this works and help.

BTW: To make changes in your directory, you will need to re-build it to see the changes. Also make a backup of your site_html_templates.pl file before trying this.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums


[This message has been edited by AnthroRules (edited February 26, 2000).]

[This message has been edited by AnthroRules (edited February 26, 2000).]
Quote Reply
Re: How do you Compare a Date Field ? In reply to
I don't think it works.
Links are displayed together on a page e.h. <%links%>. So this way you can only control a full page to be displayed or not.
If you want to control per link effect you need to change the codes in sub build_category_pages or sub site_html_link

Webmaster33
Quote Reply
Re: How do you Compare a Date Field ? In reply to
Thanks for your help on this.
When it created the pages, it did'nt seem to recognise the variable saying Unkown Tag: expire .
Do i have to set these up as global variables first ?
Maybe in the link.def or something ?
Quote Reply
Re: How do you Compare a Date Field ? In reply to
No, you define the tag in the sub that you have placed the codes (like site_html_link), like I instructed earlier.

Like the following:

Code:
expire => $expiremessage,

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: [Cyclo] How do you Compare a Date Field ? In reply to
Cyclo;

I am working on something similar to what you were doing here in the Links 2.0 forum. I wanted to set up a start date and expire date. So links would only show if start date was <= today’s date and stop showing if end date was > today’s date. I would settle for just stop showing if end date was greater than today’s date. I was wondering if you got it to work and if you could let me know how to do it on my site. Any help would be appreciated.

Thanks,Jake