Welcome Guest, Not a member yet? Register   Sign In
[Solved] Calendar - Event text within table cells
#6

[eluser]LifeSteala[/eluser]
OK peoples, I have successfully extended the Calendar class to output actual event names with a link instead of events being linked with the day number.

Your template has to change to reflect the changes.

The code is flexible, so if you pass a normal array like the one below it will still work with the default template only.

Code:
$temp = array('4' => 'http://www.mysite.com/events/2009/09/04');

However, if you wish to use an array like this one below, you will need to use the following template.

Code:
$temp = array('4' => array('My Birthday Party', 'http://www.mysite.com/events/2009/09/04'));

Adjusted Template

Code:
$prefs['template'] = '

   {table_open}<table class="cal" width="100%" border="0" cellpadding="0" cellspacing="0">{/table_open}

   {heading_row_start}<tr class="month">{/heading_row_start}

   {heading_previous_cell}<th align="center"><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
   {heading_title_cell}<th height="30" align="center" colspan="{colspan}">{heading}</th>{/heading_title_cell}
   {heading_next_cell}<th align="center"><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}

   {heading_row_end}</tr>{/heading_row_end}

   {week_row_start}<tr>{/week_row_start}
   {week_day_cell}<td class="day" width="14%" height="20" align="center">{week_day}</td>{/week_day_cell}
   {week_row_end}</tr>{/week_row_end}

   {cal_row_start}<tr>{/cal_row_start}
   {cal_cell_start}<td class="date" height="45" valign="top">{/cal_cell_start}

   {cal_cell_content}{day}<br /><a href="{content}">{event}</a>{/cal_cell_content}
   {cal_cell_content_today}<div class="highlight">{day}</div><a href="{content}">{event}</a>{/cal_cell_content_today}

   {cal_cell_no_content}{day}{/cal_cell_no_content}
   {cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today}

   {cal_cell_blank}&nbsp;{/cal_cell_blank}

   {cal_cell_end}</td>{/cal_cell_end}
   {cal_row_end}</tr>{/cal_row_end}

   {table_close}</table>{/table_close}
';

Example working code

Code:
$eventDays = array();
                
if ( $events ) {
    foreach( $events->result() as $e ) {
        $eventDays["$e->raceday"] = array($e->event_name, $e->event_url);
    }    
    echo $this->calendar->generate($year, $month, $eventDays);
} else {
    echo $this->calendar->generate($year, $month);
}

MY_Calendar.php extension code
See attached file.

Enjoy!

Thanks!


Messages In This Thread
[Solved] Calendar - Event text within table cells - by El Forum - 09-07-2009, 12:23 AM
[Solved] Calendar - Event text within table cells - by El Forum - 09-07-2009, 02:06 AM
[Solved] Calendar - Event text within table cells - by El Forum - 09-07-2009, 02:48 AM
[Solved] Calendar - Event text within table cells - by El Forum - 09-07-2009, 03:07 AM
[Solved] Calendar - Event text within table cells - by El Forum - 09-07-2009, 03:36 AM
[Solved] Calendar - Event text within table cells - by El Forum - 09-07-2009, 04:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB