Gossamer Forum
Home : Products : DBMan : Customization :

SSI and Date

Quote Reply
SSI and Date
Hello

i would call the dbman script with ssi but with the current date in it.

It is easy to do this with a normal Link wit Javascript but not with SSI.

Here is a short SSI Call:

< !--#include virtual="../cgi-bin/dbman/db.cgi?db=termine&uid=default&Bereich=Musik&sb=5&Datum-gt=18. Juli 2001&view_records=1" -- >
(the wrong space are for this forum :-)) )
The Date 18. Juli 2001 should be automaticly replaced with the current Date.

I have tried to setup the Date with the normal DATE_LOCAL Variable but with no result :-(

I hope anyone can help me ....

Quote Reply
Re: SSI and Date In reply to
Try using exec cgi...this will execute the script...include virtual is typically used to INCLUDE static files within other SSI enabled files.

Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: SSI and Date In reply to
Hmmm ... I'm having the same problem: trying to include LOCAL_DATE in a query string doesn't work. exec cmd or exec cgi don't work at all for me, even if I use a date that I know exists.
include virtual is the only syntax that works, but not with LOCAL-DATE - I assume that "include virtual" does not interpolate SSI variables.
There must be a way to code this in db.cgi, somewhere in sub query. You could pass on "date=>today" (or, in your-case: "date-gt=today") in the query-string and then code something like:

if (in{'$date-gt'} eq "today") {
$today = get_date(time();
}

and then have dbman do a range search "greater than $today" on the date field. I don't have time to code this now, perhaps later - or would someone else care to take over? :-)

kellner
Quote Reply
Re: SSI and Date In reply to
Yes you can, but the syntax you have is wrong.

Try:
Code:
if ($in{'date'} eq "today") {
$date = scalar localtime;
}
Then add &date=today into the query string and put $date where you want to print it out.

Installations:http://www.wiredon.net/gt/

Quote Reply
Re: SSI and Date In reply to
Sorry, that should have been "&get_date(time())". This is supposed to call the subroutine "get_date" in db.cgi, which prints out the date in exactly the format I want (unlike "scalar localtime").

[I edited this post, adding the missing final bracket, before Paul Wilson sent in his reply where he points it out]

kellner
Quote Reply
Re: SSI and Date In reply to
In Reply To:
Sorry, that should have been "&get_date(time()"
That isn't correct either.

Try:

&get_date(time());

or just.... $time = &get_date();

Installations:http://www.wiredon.net/gt/

Quote Reply
Re: SSI and Date In reply to
... ok, so I looked at sub query, but am out of my wits.
There are three lines in sub query which look like this:
if ($in{'date'}) { &date_to_unix($in{'date'}) }
if ($in{'date-lt'}) { &date_to_unix($in{'date-lt'}) }
if ($in{'date-gt'}) { &date_to_unix($in{'date-gt'}) }

I thought this would be the proper place to add the "today" routine. As I want to get all dates which are greater than today's (i.e. future dates), I am looking at the case where $in{'date-gt'} eq "today". So I replaced the last line with:
if ($in{'date-gt'}) {
if ($in{'date-gt'} eq "today") { &date_to_unix(time());}
else { &date_to_unix($in{'date-gt'}); }}

Problem: if the date-field is defined as "date" (and not as "alpha") in the cfg-file, this will return the error message "invalid date format". If I define date as "alpha", then greater/less-than-searches don't work.
I guess the problem lies with the following line, which follows after the ones above in db.cgi:
if ($in{'$column-gt'} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{'$column-gt'}) or return "Invalid date format: '$in{'$column-gt'}'");
push(@search_gt_fields, $i); }

So perhaps I would have to add the get-today's-date function in this block? But how?


kellner
Quote Reply
Re: SSI and Date In reply to
OK, if anyone's interested: I decided to stop reinventing the wheel and went for JPDeni's mod to call an entry depending on the current date:
http://webmagic.hypermart.net/dbman/date21.txt

This way, you can include an SSI call with "future=7" in the query-string and it will print all entries 7 days ahead from today.


kellner