如何在没有jquery完整日历插件的情况下创建日历?

时间:2015-06-19 07:23:55

标签: php codeigniter calendar

我正在尝试使用codeigniter创建一个没有jquery插件的日历。我正在创建一个变量名称' conf'。以下是我正在使用的代码。

<?php
class mycal_model extends CI_Model {
    //public  $conf;
     $conf = null;


    function  mycal_model (){
        parent::CI_Model();

         $this->conf = array(
            'show_next_prev' => True,
            'next_prev_url' => base_url().'index.php/my_calendar/showcal/'
        );

         $this->conf['cal_tempalte'] = '
             {table_open}<table border="0" cellpadding="0" cellspacing="0">{/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_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_end}</td>{/cal_cell_end}
            {cal_row_end}</tr>{/cal_row_end}

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

    function generate($year,$month){


        $this->load->library('calendar', $conf);

        $cal_data = array(
            15 => 'foo',
            23 => 'bar'
        );

        return $this->calendar->generate($year,$month,$cal_data);
    }
}

但是我收到了这个错误。

PROBLEM is Fatal error: Call to undefined method CI_Model::CI_Model() in C

如果有人能给我一个想法,或者为什么我会收到这个错误,那将是一个很大的帮助

1 个答案:

答案 0 :(得分:0)

好像您使用的是旧版本代码。 这应该工作:

<?php
class mycal_model extends CI_Model {
    //public  $conf;
     public $conf = null;


    function  __construct(){
        parent::__construct();

         $this->conf = array(
            'show_next_prev' => True,
            'next_prev_url' => base_url().'index.php/my_calendar/showcal/'
        );

         $this->conf['cal_tempalte'] = '
             {table_open}<table border="0" cellpadding="0" cellspacing="0">{/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_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_end}</td>{/cal_cell_end}
            {cal_row_end}</tr>{/cal_row_end}

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

    function generate($year,$month){


        $this->load->library('calendar', $conf);

        $cal_data = array(
            15 => 'foo',
            23 => 'bar'
        );

        return $this->calendar->generate($year,$month,$cal_data);
    }
}