Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8026 Posts in 1851 Topics- by 2099 Members - Latest Member: roi
Pages: [1]   Go Down
Print
Author Topic: PHP page including calendar  (Read 270 times)
0 Members and 1 Guest are viewing this topic.
CptVorpal
New Member
*

Karma: 0
Offline Offline

Posts: 0

Software Engineer


WWW
« on: March 15, 2006, 11:52:00 PM »

I'm having trouble integrating the calendar with my current php code. When I call calendar.cgi on its own, everything works properly. But, when I reference it via php / ssi I can't seem to get it working properly.

Directory structure
/
/cgi-bin/calendarscript/
/webroot/index.php

Here are the 3 approaches I've tried thus far:

1)
According to my hosting provider: http://www.fatcow.com/knowledgebase/read_article.bml?kbid=603

<!--#include virtual="../cgi-bin/program.cgi"-->

2) PHP function virtual
     virtual("../cgi-bin/calendar.cgi");

3) PHP function include
     include("../cgi-bin/calendar.cgi");

All 3 don't render any results on the page. Any thoughts where I can at least begin looking?


Logged
a_php_dude
Guest
« Reply #1 on: January 03, 2007, 02:28:00 AM »

I did this and it works.

Of course I have seperate php files for each view, the internal links within the script's template files are hacked to call upon the php scripts instead of the cgi script directly, and with some imagination you can also use .htaccess to make some of the variables more SEO-friendly.

This executes the cgi script and displays it from within your php script:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.[your-site-url].com/cgi-bin/calendar/calendar.pl?template=".$_GET['template']."&view=".$_GET['view']."&calendar=".$_GET['calendar']."&event_id=".$_GET['event_id']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);

Your php script can actually pass variables to the cgi script this way, I just gave them the same names in the above example to make it simpler. So after setting this up you could visit your file:
URL/directory/some/where/file.php?View=monthly&calendar=default&month=1&year=2007

The number of variables and what they are called are passed individually and specified within the php script, so it does become less flexible (if anyone has a better way be my guest) unless you simply write more than one php script, or write your php script with its own variables that choose between a selection of curl-setopt("URL")'s at runtime.

In my own calendar, I *only* use the monthly view and I have a heavily modified event view. So I also set up .htaccess rules:

RewriteRule ^/(.*)/(.*)/ cgi-bin/calendar/calendar.pl?year=$2&month=$3 [L]

Thus people go to my site's [URL]/1/2007/ to view month 1, year 2007 and the URL is squeaky clean. The links on the calendar grid are modified to [URL]/event-101 using the same methodology:

RewriteRule ^event-(.*) /cgi-bin/calendar/calendar.pl&View=event&event_id=$1 [L]

Good luck!

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #2 on: January 03, 2007, 02:07:00 PM »

** All 3 don't render any results on the page. **

What IS rendered in place of those tags???

If the SSI call had failed, an error message would be displayed in place of the tag. If the page had not even been parsed, the SSI tag would still remain in the page source code.

JFYI

Dan O.

------------------

Logged
Pages: [1]   Go Up
Print
Jump to: