Yii 2.0: yii2fullcalendar

yii2 efullcalendar.js extension
12 followers

yii2fullcalendar

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

JQuery Documentation: http://arshaw.com/fullcalendar/docs/ Yii2 Extension by philipp@frenzel.net

A tiny sample can be found here: http://yii2fullcalendar.beeye.org

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:

 "philippfrenzel/yii2fullcalendar":"*",

Usage

Quickstart Looks like this:

$events = array();
  //Testing
  $Event = new \yii2fullcalendar\models\Event();
  $Event->id = 1;
  $Event->title = 'Testing';
  $Event->start = date('Y-m-d\Th:m:s\Z');
  $events[] = $Event;
 
  $Event = new \yii2fullcalendar\models\Event();
  $Event->id = 2;
  $Event->title = 'Testing';
  $Event->start = date('Y-m-d\Th:m:s\Z',strtotime('tomorrow 6am'));
  $events[] = $Event;
 
  ?>
 
  <?= \yii2fullcalendar\yii2fullcalendar::widget(array(
      'events'=> $events,
  ));

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

AJAX Usage

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

<?= yii2fullcalendar\yii2fullcalendar::widget(array(
      'ajaxEvents' => Url::to(['/timetrack/default/jsoncalendar'])
    ));
?>

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

public function actionJsoncalendar($start=NULL,$end=NULL,$_=NULL){
    $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 \yii2fullcalendar\models\Event();
      $Event->id = $time->id;
      $Event->title = $time->categoryAsString;
      $Event->start = date('Y-m-d\Th:m:s\Z',strtotime($time->date_start.' '.$time->time_start));
      $Event->end = date('Y-m-d\Th:m:s\Z',strtotime($time->date_start.' '.$time->time_end));
      $events[] = $Event;
    }
 
    header('Content-type: application/json');
    echo Json::encode($events);
 
    Yii::$app->end();
  }

Total 9 comments

#20085 report it
ric_ardo at 2017/06/05 04:24pm
Language not changing

Hi,

Congratulations! Good work!

I am trying change default language of my fullcalendar. I am using this code:

<?= yii2fullcalendar\yii2fullcalendar::widget([
                'options' => [
                  'language' => 'pt-br',
                  //... more options to be defined here!
                ],
                'events' => $events
              ]);
        ?>

But it does not change it. Continue with English language. What is wrong? Can you help me pls?

Tks advanced.

#19963 report it
manocreative at 2016/10/22 05:47am
Add google calendar

Hi can you tell me how to user google calendar in this widgets.Also how to combine google calendar events and json events.Can you please tell me...

#19766 report it
ptr.nov at 2016/01/31 01:44am
model Timetable

I do not find models Timetable.

#19346 report it
PinkBrainPlan at 2015/05/28 02:58am
Thx!

I'll check and updated my readme at github! Pls. if possible, always post issues like this on github too, as it's much easier to keep track of this!

#19345 report it
IRCSASW at 2015/05/28 12:01am
error in date() function

the correct way is to use "i" instead of "m" for minutes.

...
$Event->start = date('Y-m-d\Th:i:s\Z',strtotime($time->date_start.' '.$time->time_start));
...
#19261 report it
dustbin1_uk at 2015/05/02 05:34pm
update event back to DB

I have made my events editable, so I can drag them around to try and update them.

But I am trying to figure what fullcalender function I should use when I have dragged one of those events from one day to another, to call the controller and update the database.

I tried to use the eventDragStop event, but the date on the event being dragged is still the old one at that point (unless I have done something wrong).

Do you know how I go about passing the event from the calender widget back to my controller after I have dragged the event to a new day, or even resized the event in day view?

EDIT: To answer this for anyone else with this question:

eventResize http://fullcalendar....ui/eventResize/

eventDrop http://fullcalendar....t_ui/eventDrop/

The former is used when you resize an event to make it longer or shorter The later is for when you drag an entire event from one date\time to another

#19226 report it
dustbin1_uk at 2015/04/24 08:36am
404 error on files

Would you happen to know if the following is due to an error in the extension, or an error in my implementation?

http://www.yiiframework.com/forum/index.php/topic/63383-fullcalendar-404-error-on-dependant-files/

#19010 report it
PinkBrainPlan at 2015/02/25 07:49am
attach event drop

Hi IRCSASW,

pls. check out the latest docs at github and the full sample repository:

https://github.com/philippfrenzel/yii2fullcalendar-demo

If you still don't get it to run, pls. open an github issue:

https://github.com/philippfrenzel/yii2fullcalendar/issues

Thanks

#19007 report it
IRCSASW at 2015/02/24 11:28pm
attach event drop

How can attach event drop?

<?= \yii2fullcalendar\yii2fullcalendar::widget(array(
  'ajaxEvents' => Url::to(['/site/jsoncalendar']),
  'clientOptions' => [
    'editable' => true,
    'droppable' => true,
    'drop' => ????????
  ],
));
?>

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet