Yii2 Fullcalendar
An implementation of fullcalendar v3.
For more information read documentation., (*1)
, (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
php composer.phar require --prefer-dist claudejanz/yii2-fullcalendar "*"
or add, (*5)
"claudejanz/yii2-fullcalendar": "*"
to the require section of your composer.json
file., (*6)
Usage
Once the extension is installed, simply use it in your view by:, (*7)
echo \claudejanz\yii2fullcalendar\Fullcalendar::widget([
'clientOptions' => [
'events' => \yii\helpers\Url::to(['site/events']),
'weekends' => false,
'defaultView' => 'agendaWeek',
'editable' => false,
'header' => [
'left' => 'prev,next today ',
'right' => 'month,agendaWeek,agendaDay'
],
]
]);
And in your controller by:, (*8)
public function actionEvents($start=NULL,$end=NULL,$timestamp=NULL){
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$format = \DateTime::ISO8601;
$events = [];
$date = new \DateTime('now');
$event = new \claudejanz\yii2fullcalendar\models\Event();
$event->title = "An event";
$event->start = $date->format($format);
$date->add(new \DateInterval('PT1H'));
$event->end = $date->format($format);
$events[] = $event;
return $events;
}