Forum Moderators: coopster
First thanks for helping me with my PHP/SSI question from an earlier thread. Allow me to throw another question at the group which should be real simple.
I have my PHP calendar script that I uploaded to the server and viewing the calendar directly, it works great. The calendar is located at:
mydomain.com/calendar/index.php
I want to integrate this on my website, so I added this line to where I want it to appear on the appropriate page:
<?php require("calendar/index.php");?>
It displays great. Trouble is, the css file and advancing to the next month are not working, because the relative links aren't pointing to the calendar folder, but instead are pointing to the root of mydomain.com.
How do I get the links to point to the calendar folder?
In file /index.php, above the line of requiring the calendar, add another line:
define("IN_WEB", 1);
Then in the head of /calendar/index.php, add such lines:
if (defined("IN_WEB")) define("PATH_CALENDAR", "calendar/");
else define("PATH_CALENDAR", "./");
And then prefix the constant PATH_CALENDAR to all your links including css files on the page /index.php
Thanks for your help.
That all makes sense to me except the "prefix the constant" part. In the example of the css file, I did this which just doesn't "feel" right (and it didn't work!):
<link href="PATH_CALENDAR/images/cal.css" rel="stylesheet" type="text/css">
I'm sure I'm missing something real basic here.
Here's one of my links that I need to set the constant in.
<a href="<? echo "index.php?month=$prev_month&year=$prev_year";?>"
This calendar is a small program, but there are several places where I would need to do this making the template option appealing. However, I am lost on where to start with that as well. Again, a recommendation to a good tutorital would be appreciated.
Thank you for your patience with me.
<a href="<? echo PATH_CALENDAR . "index.php?month=$prev_month&year=$prev_year";?>">
since the dot "." is an operator that joins strings together.
PATH_CALENDAR is a constant, which is similar to a variable except that its value can't be changed in the whole page once it's defined.
PHP Manual is a good tutorial. Details about constants and variables are described in the Language Reference part.
You will find everything about how to use PHP in PHP Manual, but if you want to ask how to use PHP well, I'd like to say Practice Makes Perfect. Additionally, learning new technologies and nice methods on the Web to solve problems more efficiently and communicating with others are indispensable.