gpt4 book ai didi

php - 如何通过 codeigniter 日历库在当前月份的空单元格中填充上个月和下个月的日期

转载 作者:搜寻专家 更新时间:2023-10-31 21:29:13 24 4
gpt4 key购买 nike

我正在使用 Codeigniter 日历在网页中显示用户事件,问题是显示没有日期的空单元格。我在下面显示了我的屏幕截图。

enter image description here

在上图中,我用蓝色点缀了空单元格,所以在这里我想用不同的颜色显示上个月和下个月的日期。我该怎么做?

我的示例 CI 日历库代码是:

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}&nbsp;{/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);

}

最佳答案

在你的$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
);

此外,您的每个 bool 值都应该没有引号(如果是“FALSE”,它根本不起作用)。 Reference .

关于php - 如何通过 codeigniter 日历库在当前月份的空单元格中填充上个月和下个月的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31988039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com