calendar

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

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

calendar

Post by kpraman »

I have downloaded a calendar from

http://www.cascade.org.uk/software/php/ ... /index.php

Can any pls tell me how to use getDateLink with an example?

Code: Select all

($day, $month, $year)
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Funny, the guy that wrote the script already did that... go figure: http://www.cascade.org.uk/software/php/ ... inking.php
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

i tried, its not working
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

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)
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Try

Code: Select all

$cal=new MyCalendar;
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

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
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Looks like you got it working then
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

No. I am only seeing the text, 'first.php'
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

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 »

How do i display calendar with link?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

I'd just be reading the documentation for you and regurgitating it here. Read: http://www.cascade.org.uk/software/php/ ... /index.php
User avatar
bert4
Forum Newbie
Posts: 18
Joined: Wed Apr 18, 2007 9:44 am
Location: Bali, Indonesia

Post by bert4 »

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();

?>
Post Reply