claudejanz/yii2-fullcalendar

an implementation of fullcalendar v3

1.0.0 2016-09-07 18:03 UTC

This package is auto-updated.

Last update: 2024-04-11 18:05:46 UTC


README

An implementation of fullcalendar v3. For more information read documentation.

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist claudejanz/yii2-fullcalendar "*"

or add

"claudejanz/yii2-fullcalendar": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your view by:

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:

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;
  }