Welcome Guest, Not a member yet? Register   Sign In
Filling the Calendar class's events via db
#1

[eluser]Leon Stafford[/eluser]
Hi,

I'm hoping to use the calendar class to display the current and next month's event days on a site's front page. Admin will add events to the db via CMS, when calendar is generated, it will check event db and fill array with dates containing events and corresponding links to that day's event page.

Some questions:

How do I dynamically generate the array (syntax wise)?

If I want to cache the top page and don't have access to CRON, what is the best practice way to balance between caching efficiency and ensuring the page is refreshed if the date or other db content has changed? (Can I just call it conditionally via the controller depending on wether the database has changed since last cache?)

Here is my calendar output code so far:

Code:
//get this month and next month's details. ie 17th February, 2009
$days_in_month = date('t'); //ie 28
$todays_date = date('d'); //17
$this_month = date('n'); //2
$next_month = date('n', strtotime('next month')); //3
$this_months_year = date('Y'); //2009
$next_months_year = date('Y', strtotime('next month')); //2009 (if this month is Dec, this will be 2010)

$this_month_events = array(
               3  => 'view/event/'.$this_months_year.'/'.$this_month.'/3',
               7  => 'view/event/'.$this_months_year.'/'.$this_month.'/7',
               13 => 'view/event/'.$this_months_year.'/'.$this_month.'/13',
               26 => 'view/event/'.$this_months_year.'/'.$this_month.'/26'
             );
$next_month_events = array(
               1  => 'view/event/'.$this_months_year.'/'.$this_month.'/1',
               25 => 'view/event/'.$this_months_year.'/'.$this_month.'/25',
               13 => 'view/event/'.$this_months_year.'/'.$this_month.'/13',
               27 => 'view/event/'.$this_months_year.'/'.$this_month.'/27'
             );            

echo $this->calendar->generate($this_months_year,$this_month,$this_month_events);
if ($days_in_month/2 < $todays_date){
    //show next month's date if past the first half of this month
    echo $this->calendar->generate($next_months_year,$next_month,$next_month_events);
    //if adding a next month button, conditionally add it here
}


Messages In This Thread
Filling the Calendar class's events via db - by El Forum - 02-19-2009, 06:42 PM
Filling the Calendar class's events via db - by El Forum - 02-19-2009, 08:33 PM
Filling the Calendar class's events via db - by El Forum - 02-20-2009, 03:00 AM
Filling the Calendar class's events via db - by El Forum - 03-13-2009, 09:07 AM
Filling the Calendar class's events via db - by El Forum - 03-13-2009, 08:02 PM
Filling the Calendar class's events via db - by El Forum - 03-14-2009, 11:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB