简体   繁体   中英

Fullcalendar codeigniter 1.7.2

I have a calendar event using fullcalendar jQuery would I implement in codeigniter 1.7.2

When I would implement such a function fullcalendar getEvenByCategory , even not appear at all

This is my controller [kalender.php]

function json_kategori($id) {
    header("Content-Type: application/json");
    echo $this->MKalender->jsonEventsByKategori();
}

function kategori($id) {
    $query = $this->db->query("
            SELECT
                COUNT(*) as jml from kalender
            WHERE
                `IDKategori` = '$id'
            ");
    foreach ($query->result() as $row) {
        $row = $row->jml;
    }
    $config['base_url'] = base_url() . 'kalender/kategori/' . $id . '/';
    $config['total_rows'] = $row;
    $config['per_page'] = '4';
    $config['uri_segment'] = 4;
    $config['first_link'] = 'Awal';
    $config['last_link'] = 'Akhir';
    $config['next_link'] = 'Selanjutnya';
    $config['prev_link'] = 'Sebelumnya';
    $this->pagination->initialize($config);
    $data['kalender'] = $this->MKalender->getAllKalenderByKategori($id,
                    $config['per_page'], $this->uri->segment(4));

    $data['kategori'] = $this->MKategoriKalender->getKategori($id);
    $data['title'] = $data['kategori']['kategori'];
    $data['main'] = 'kalender/kalender_kategori';
    $this->load->vars($data);
    $this->load->view('layout/template');
}

this is my model [mkalender.php]

function jsonEventsByKategori($catid) {
    $sql = "
        SELECT
                *
        FROM
                kalender
        WHERE
                IDKategori = $catid
        ORDER BY
                TanggalMulai";
    $query = $this->db->query($sql);
    // echo $sql;
    return $query->result_array();
    $jsonevents = array();
    foreach ($query as $entry) {
        $jsonevents[] = array(
            'id' => $entry->IDKalender,
            'start' => $entry->TanggalMulai,
            'end' => $entry->TanggalAkhir,
            'title' => $entry->judul,
            'body' => $entry->konten,
            'multi' => 0,
            'allDay' => false,
            'extension_id' => 2
        );
    }
    return json_encode($jsonevents);
}

in this my view [kalender/kalender_kategori.php]

<script type='text/javascript'>
$(document).ready(function() {
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
    $('#calendar').fullCalendar({
        firstDay:'1',
        theme:true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,
        events: '<?= base_url(); ?>kalender/json_kategori'
    });
});</script>

<div id="main"><div id='calendar'></div></div>

so my question is, how the application code in the model to display calendar events by category events?

1) you are missing a paremeter whn jsonEventsByKategori is called.

function json_kategori($id) {
  header("Content-Type: application/json");
   echo $this->MKalender->jsonEventsByKategori(jsonEventsByKategori); //here
}

2)In your model, since you have already returned the result_array.... the jsonevents[] part will not be executed... so u can return the result_array() in model and do the foreach loop in controller...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM