我使用Codeigniter日历在网页中显示用户事件,问题是显示没有日期的空单元格。我在下面显示了我的截图。
在上面的图像中,我用蓝色点缀了空单元格,所以在这里我想用不同的颜色显示上个月和下个月的日子。我怎么能这样做?
我的示例CI Calendar Lib代码是:
public function myCalendar($year = null, $month = null)
{
$config = array(
'start_day' => 'monday',
'show_next_prev' => 'TRUE',
'day_type' => 'short',
'next_prev_url' => base_url().'testSiteC/myCalendar'
);
$events = array(
'1' => 'my birthday',
'10' => 'test'
);
$config['template'] = '
{table_open}<table border="0" cellpadding="0" cellspacing="2" class="calendar_table_big">{/table_open}
{heading_row_start}<tr>{/heading_row_start}
{heading_previous_cell}<th><a href="{previous_url}"><img src="assets/images/trainer/solid_left_arrow.png" height="15" /></a></th>{/heading_previous_cell}
{heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}"><img src="assets/images/trainer/solid_right_arrow.png" height="15" /></a></th>{/heading_next_cell}
{heading_row_end}</tr>{/heading_row_end}
{week_row_start}<tr class="week_row">{/week_row_start}
{week_day_cell}<td>{week_day}</td>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
{cal_row_start}<tr class="cell_row">{/cal_row_start}
{cal_cell_start}<td>{/cal_cell_start}
{cal_cell_start_today}<td>{/cal_cell_start_today}
{cal_cell_start_other}<td class="other-month">{/cal_cell_start_other}
{cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content}
{cal_cell_content_today}<div class="highlight"><a href="{content}">{day}</a></div>{/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} {/cal_cell_blank}
{cal_cell_other}{day}{cal_cel_other}
{cal_cell_end}</td>{/cal_cell_end}
{cal_cell_end_today}</td>{/cal_cell_end_today}
{cal_cell_end_other}</td>{/cal_cell_end_other}
{cal_row_end}</tr>{/cal_row_end}
{table_close}</table>{/table_close}
';
$this->load->library('calendar', $config);
$data['minicalendar'] = $this->calendar->generate($year, $month, $events);
$this->load->view('testSite/myCalendar', $data);
}
答案 0 :(得分:1)
在$config
数组集元素中:
$config = array(
'start_day' => 'monday',
'show_next_prev' => TRUE,
'day_type' => 'short',
'next_prev_url' => base_url().'testSiteC/myCalendar',
'show_other_days' => TRUE,// add this
);
此外,每个布尔值都应该没有引号(如果为'FALSE'则根本不起作用)。 Reference