hjp1011/yii2-fullcalendar

Yii2 fullcalendar Widgets

1.0.0 2023-05-16 18:09 UTC

This package is not auto-updated.

Last update: 2024-11-13 01:10:37 UTC


README

JQuery Fullcalendar Yii2 Extension JQuery from: http://arshaw.com/fullcalendar/ Version 2.1.1 License MIT

JQuery Documentation: http://arshaw.com/fullcalendar/docs/

A tiny sample can be found here: http://yii2-fullcalendar.beeye.org

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Installation

Package is although registered at packagist.org - so you can just add one line of code, to let it run!

add the following line to your composer.json require section:

  "hjp1011/yii2-fullcalendar":"*",

or run:

$ php composer.phar require hjp1011/yii2-fullcalendar "*"

And ensure, that you have the following plugin installed global:

php composer.phar global require "fxp/composer-asset-plugin:~1.0"

Usage

Quickstart Looks like this:

  $events = array();
  //Testing
  $Event = new \yii2-fullcalendar\models\Event();
  $Event->id = 1;
  $Event->title = 'Testing';
  $Event->start = date('Y-m-d\TH:i:s\Z');
  $event->nonstandard = [
    'field1' => 'Something I want to be included in object #1',
    'field2' => 'Something I want to be included in object #2',
  ];
  $events[] = $Event;

  $Event = new \yii2-fullcalendar\models\Event();
  $Event->id = 2;
  $Event->title = 'Testing';
  $Event->start = date('Y-m-d\TH:i:s\Z',strtotime('tomorrow 6am'));
  $events[] = $Event;

  ?>

  <?= \yii2-fullcalendar\yii2-fullcalendar::widget(array(
      'events'=> $events,
  ));

Note, that this will only view the events without any detailed view or option to add a new event.. etc.

Non-Standard fields

You can add non-standard fields via the non-standard fields array, for which you can pass any key/value pair, as described in the Event Fields documentation.

So, using the Quick Start example above, you can read field1 and fields2 in your JavaScript using notation similar to event.nonstandard.field1 and event.nonstandard.field2.

AJAX Usage

If you wanna use ajax loader, this could look like this:

20171023 ajaxEvents are replaced by events - pls. check fullcalendar io documentation for details

<?= yii2-fullcalendar\yii2-fullcalendar::widget([
      'options' => [
        'lang' => 'de',
        //... more options to be defined here!
      ],
      'events' => Url::to(['/timetrack/default/jsoncalendar'])
    ]);
?>

and inside your referenced controller, the action should look like this:

public function actionJsoncalendar($start=NULL,$end=NULL,$_=NULL){

    \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

    $times = \app\modules\timetrack\models\Timetable::find()->where(array('category'=>\app\modules\timetrack\models\Timetable::CAT_TIMETRACK))->all();

    $events = array();

    foreach ($times AS $time){
      //Testing
      $Event = new \yii2-fullcalendar\models\Event();
      $Event->id = $time->id;
      $Event->title = $time->categoryAsString;
      $Event->start = date('Y-m-d\TH:i:s\Z',strtotime($time->date_start.' '.$time->time_start));
      $Event->end = date('Y-m-d\TH:i:s\Z',strtotime($time->date_end.' '.$time->time_end));
      $events[] = $Event;
    }

    return $events;
  }