我是CakePHP的新手,并希望使用此框架创建日历。我有一段困难时期,我想知道是否有关于如何使用CakePHP创建简单日历的教程或指南?
答案 0 :(得分:4)
答案 1 :(得分:1)
答案 2 :(得分:0)
function feeds(){ $this->layout = 'ajax'; if(isset($this->params->query['start'])){ $start = $this->params->query['start']; } if(isset($this->params->query['end'])){ $end = $this->params->query['end']; } $events = $this->{$this->modelClass}->find('all',array('conditions' => array('startdate >=' => $start,'enddate $end))); $data = ''; foreach($events as $res ){ $data[] = array( 'id' => $res[$this->modelClass]['id'], 'title'=> $res[$this->modelClass]['title'], 'start'=> Date('Y-m-d H:m',$res[$this->modelClass]['startdate']), 'end' => Date('Y-m-d H:m',$res[$this->modelClass]['enddate']), 'start_time' => Date('h:ia',$res[$this->modelClass]['startdate']), 'end_time' => Date('h:ia',$res[$this->modelClass]['enddate']) ); } echo json_encode($data); exit; }
<div class="" id="calendar_div">
视图文件的Js代码
$('#calendar_div').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'agendaDay,agendaWeek,month'
},
defaultView: 'month',
events: '<?php echo $this->Html->url(array('action' => 'feeds')); ?>',
selectable: true,
selectHelper: true
});