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

标签 php codeigniter

我正在使用 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/

相关文章:

php - Voyager 安装 Laravel 上的外键约束格式不正确

php - Mysql 两张表,获取没有相同值的数据

javascript - Ajax 调用在 CodeIgniter 中不起作用

mysql - 如何将form_dropdown id值添加到数据库? - 代码点火器

php - Laravel:如何获取分配给特定代理的客户的所有订单

php - Plupload:如何从 PHP 处理脚本中获取文件名

php - 将 $_GET 变量从 Wordpress 页面传递到外部 iFrame

php - 需要帮助创建触发器 phpmyadmin

php - 使用sql查询和模型codeigniter将数据复制到另一个表

php - 如何使用codeigniter从数据库中检索值