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

template condition by date?

Quote Reply
template condition by date?
So we have these images that all of them changed to a new format after a certain date (say DATE X), is there a way to do something like this? Basically how do you do a date comparison in a template OR what kind of global would dump out 1 or 0 if date1 > date2?

Code:
<%set orientation = 'portrait'%>
<%if $date > Feb 7%>
<%set tablewidth = 758%>
<%else%>
<%set tablewidth = 1053%>
Quote Reply
Re: [scorpioncapital] template condition by date? In reply to
Oh, this would be an interesting issue!

If this is possible, I would use this to setup different logos, eg. for easter, xmas, halloween,... just as google does.

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.

Last edited by:

ManuGermany: Feb 10, 2004, 11:51 PM
Quote Reply
Re: [ManuGermany] template condition by date? In reply to
probably you need a global that imports the Date class and just spits out 1 or 0 depending on whether it's greater than or less than. I was just wondering if you can reference the date class directly the template and make it faster than using a global....
Quote Reply
Re: [scorpioncapital] template condition by date? In reply to
If you have 'date' as a variable it depends what format it is in - if it is yyyy-mm-dd then you could just use

<%if date > '2004-02-07'%>

If you want to compare today with a date, you can do

<%set today = GT::Date::date_get%>
<%if today > '2004-02-07'%> ...

You can use all the Date functions in a template - so you can also use date_sub, etc.

Quote Reply
Re: [afinlr] template condition by date? In reply to
In Reply To:
If you have 'date' as a variable it depends what format it is in - if it is yyyy-mm-dd then you could just use

<%if date > '2004-02-07'%>


Would this work? Doesn't this require date comparison instead of string comparison?
Quote Reply
Re: [scorpioncapital] template condition by date? In reply to
Try it and see Wink
Quote Reply
Re: [scorpioncapital] template condition by date? In reply to
If you are using a global, you might have to specifically request initializing

Links::init_date();

Then, set your date format, and do a comparason. The on-line docs in the admin-> help system are pretty good.

The Links date routines are good enough that I've rewritten some of my older code to not include the DateTime modules. You just need to make sure you specify what you want, and don't assume that it's set up the way you want.

Once you do that, you can use simple date comparson routines -- for actual examples look in Build.pm.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [afinlr] template condition by date? In reply to
Might work, the silly 'if' construct though, for some reason you got to put the date in a variable if you just try to compare two dates in strings, some reason doesn't work...