在codeigniter日历中创建一个链接

时间:2017-01-29 13:29:28

标签: php codeigniter

我正在使用codeigniter 3.x版本,在我的一个页面上,我想显示一个日历,其中每天(等于或大于今天)将成为一个链接。

我的控制器代码如下所示:

 $prefs = array(
            'start_day'    => 'monday',
            'month_type'   => 'long',
            'day_type'     => 'short',
            'show_next_prev'  => TRUE,
            'next_prev_url'   => base_url().'Hall/display_calendar/'
        );

        $prefs['template'] = '
            {table_open}<table class="call_table" cellspacing="0" cellpadding="0" border="0" style="margin:0 auto;">{/table_open}
            {heading_row_start}<tr>{/heading_row_start}
            {heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
            {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
            {heading_next_cell}<th><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>{week_day}</td>{/week_day_cell}
            {week_row_end}</tr>{/week_row_end}
            {cal_row_start}<tr>{/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}
            // THIS IS THE LINE WHERE I AM TRYING TO CREATE THE LINK
            {cal_cell_content}<a href="'.base_url().'Hall/display_calendar/"{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', $prefs);

视图中,我就是这样:

    echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));

此代码有效,即显示日历,下一个月和前几个月的链接工作正常,但是没有生成链接。

果然,即使上面的代码以某种方式工作,日历中的所有日子都将是链接。我可以忍受这一点,但如果我能够设法让过去的日子不成为链接,那将是最好的。

我发现this solution以及this one与我的问题有某种关系,但这里没有任何作用。

任何帮助?

1 个答案:

答案 0 :(得分:0)

我会将此作为评论,但我还没有声誉。我可以查看视图中生成的日历的HTML吗?这可以在链接格式化时排除任何HTML怪癖。

{content}之前是否有额外的引用?:

a href="'.base_url().'Hall/display_calendar/"{content}"