PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Thu Apr 19, 2007 5:19 am
i tried, its not working
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Thu Apr 19, 2007 5:26 am
This is how i wrote,
Code: Select all
class MyCalendar extends Calendar
{
function getDateLink($day, $month, $year)
{
// Only link the first day of every month
$link = "";
if ($day == 1)
{
$link = "first.php";
}
return $link;
}
}
$cal=new Calendar;
echo $cal->getDateLink(1, 4, 2007)
aaronhall
DevNet Resident
Posts: 1040 Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:
Post
by aaronhall » Thu Apr 19, 2007 5:39 am
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Thu Apr 19, 2007 5:56 am
Code: Select all
class MyCalendar extends Calendar
{
function getDateLink($day, $month, $year)
{
// Only link the first day of every month
$link = "";
if ($day == 1)
{
$link = "first.php";
}
return $link;
}
}
$cal=new MyCalendar;
echo $cal->getDateLink(1, 4, 2007);
OUTPUT: first.php
aaronhall
DevNet Resident
Posts: 1040 Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:
Post
by aaronhall » Thu Apr 19, 2007 5:59 am
Looks like you got it working then
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Thu Apr 19, 2007 6:01 am
No. I am only seeing the text, 'first.php'
aaronhall
DevNet Resident
Posts: 1040 Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:
Post
by aaronhall » Thu Apr 19, 2007 6:11 am
Right, that's what it's supposed to do.
kpraman
Forum Contributor
Posts: 172 Joined: Fri Oct 13, 2006 10:54 am
Post
by kpraman » Thu Apr 19, 2007 6:12 am
How do i display calendar with link?
bert4
Forum Newbie
Posts: 18 Joined: Wed Apr 18, 2007 9:44 am
Location: Bali, Indonesia
Post
by bert4 » Thu Apr 19, 2007 7:47 am
Well it took me a while to figure it out
You need to understand that the function getDateLink is used by the calendar class to find out if a link needs to be displayed.....
So, if you have dates that need to be linked, they have to be retrieved by this function.
This works:
Code: Select all
<?
require('calendar.php'); // the calendar class
class MyCalendar extends Calendar
{
function getDateLink($day, $month, $year)
{
if ($day == 1 AND $month == 4 AND $year == 2007) { $link = "first.php"; }
if ($day == 10 AND $month == 4 AND $year == 2007) { $link = "tenth.php"; }
return $link;
}
}
$cal=new MyCalendar;
echo $cal->getCurrentMonthView();
?>