Yii 1.1: efullcalendar

Arshaw's FullCalendar as Yii extension
33 followers

This is so far the best calendar library I've seen in my life :) That's what I call a rapid development.

Installation

Just unpack to extensions directory.

Usage

$this->widget('ext.EFullCalendar.EFullCalendar', array(
    // polish version available, uncomment to use it
    // 'lang'=>'pl',
    // you can create your own translation by copying locale/pl.php
    // and customizing it
 
    // remove to use without theme
    // this is relative path to:
    // themes/<path>
    'themeCssFile'=>'cupertino/theme.css',
 
    // raw html tags
    'htmlOptions'=>array(
        // you can scale it down as well, try 80%
        'style'=>'width:100%'
    ),
    // FullCalendar's options.
    // Documentation available at
    // http://arshaw.com/fullcalendar/docs/
    'options'=>array(
        'header'=>array(
            'left'=>'prev,next',
            'center'=>'title',
            'right'=>'today'
        ),
        'lazyFetching'=>true,
        'events'=>$calendarEventsUrl, // action URL for dynamic events, or
        'events'=>array() // pass array of events directly
 
        // event handling
        // mouseover for example
        'eventMouseover'=>new CJavaScriptExpression("js_function_callback"),
    )
));

Example action

public function actionCalendarEvents()
{
    $items[]=array(
        'title'=>'Meeting',
        'start'=>'2012-11-23',
        'color'=>'#CC0000',
        'allDay'=>true,
        'url'=>'http://anyurl.com'
    );
    $items[]=array(
        'title'=>'Meeting reminder',
        'start'=>'2012-11-19',
        'end'=>'2012-11-22',
 
        // can pass unix timestamp too
        // 'start'=>time()
 
        'color'=>'blue',
    );
 
    echo CJSON::encode($items);
    Yii::app()->end();
}

Result

Result

Homepage

Total 20 comments

#18144 report it
Azy at 2014/09/16 02:46am
Why my events are always coming in All day event slot?

Here is my data,

    $items[] = array(
        'title' => 'Meeting',
        'start' => strtotime('2014-09-09'),
        'color' => '#CC0000',
        'allDay' => true,
        'url' => 'http://anyurl.com'
    );
    $items[] = array(
        'title' => 'Meeting reminder',
        'start' => '2014-09-15 05:20:17',
        'end' => '2014-09-15 05:30:17',
        'color' => 'blue',
    );

    echo CJSON::encode($items);
    Yii::app()->end();

And another issue i have is when enable true as below, it says

'editable'=>'true',
'selectable' => true,

Property "EFullCalendar.editable" is not defined.

#17550 report it
colombo at 2014/07/01 05:11am
eventDrop... helppppp

This is my my option array into the widget: 'options'=>array( 'editable'=>true, 'eventDrop'=>'function(event, delta, revertFunc, jsEvent, ui, view) { alert(event.title+" ora in "+ event.start.format()); }', .... ) i get the follow js error wher i try move an event to a different day: TypeError: options[name].apply is not a function in http://localhost/immobiliare/assets/ed9bd66f/fullcalendar/fullcalendar.js:643

Somebody can help me to understand which is the problem??

#17549 report it
colombo at 2014/07/01 04:45am
Thanks

You are right...

#17547 report it
bandpay at 2014/07/01 02:58am
@colombo

@colombo

I think that you have not defined the events in the options section. Take a closer look at the code snippets on this page.

Good luck

'options'=>array(
        'header'=>array(
            'left'=>'prev,next',
            'center'=>'title',
            'right'=>'today'
        ),
        'lazyFetching'=>true,
        'events'=>$calendarEventsUrl, // action URL for dynamic events, or
        'events'=>array() // pass array of events directly
 
        // event handling
        // mouseover for example
        'eventMouseover'=>new CJavaScriptExpression("js_function_callback"),
    )
#17540 report it
colombo at 2014/06/30 09:49am
Help... my views displays so:

[{"title":"Meeting","start":1394319600,"color":"#CC0000","allDay":true,"url":"http:\/\/anyurl.com"},{"title":"Meeting reminder","start":1394406000,"end":1394492400,"color":"blue"}]

my controller is public function actionIndex()

{

  $items[]=array(
      'title'=>'Meeting',
      'start'=>strtotime('2014-03-09'),
      'color'=>'#CC0000',
      'allDay'=>true,
      'url'=>'http://anyurl.com'
  );
  $items[]=array(
      'title'=>'Meeting reminder',
      'start'=>strtotime('2014-03-10'),
      'end'=>strtotime('2014-03-11'),
      'color'=>'blue',
  );

  echo CJSON::encode($items);
  Yii::app()->end();

}

my views is: <?php $this->widget('ext.EFullCalendar.EFullCalendar', array( 'themeCssFile'=>'cupertino/jquery-ui.min.css', 'options'=>array( 'header'=>array( 'left'=>'prev,next', 'center'=>'title', 'right'=>'today' ) ))); ?>

where is my mistake??

#17344 report it
Todd Anstis at 2014/05/27 12:32pm
Server problems

@AhmedK make sure your server isn't case sensitive - check the spelling of your code against the name and path of the widget.

#17343 report it
AhmedK at 2014/05/27 11:27am
server problem !!

hi guys :) i used this extention in my project and it's worked fine on localhost but when i puted the website on server it says

The alias " ext.EFullCalendar.EFullCalendar" is invalid. Check that points to an existing PHP file.

also when i tried application.extensions.EFullCalendar.EFullCalendar it doesn't work did anyone had the same problem with this extension on server !!

#17289 report it
Todd Anstis at 2014/05/19 08:36pm
ajax renderpartial?

first off - incredible extension. this has made my entire project possible, and for that i'm grateful. i'm using this in several different places throughout my app, but i ran into a problem today. in my page i have a div that i load via ajax/renderpartial that contains the EFullCalendar. when i visit the page on my (slow) Macbook pro dev machine, it works fine. when i deploy to my (lightning fast) production environment on AWS EB, its almost like the assets load last - the div loads, i get an error saying $(...).fullCalendar is not a function and in Firebug i can see that fullcalendar.js loads way after the error. how can i make this extension work via renderpartial/ajax?

#17137 report it
ThePr0f3550r at 2014/05/07 01:02am
New Extension EFullCalendarHeart

I am only make this extension support with Arshaw FullCalendar version 2.XX Check it EFullCalendarHeart

#16611 report it
realtebo at 2014/03/10 11:50am
Please use forum, not comment for discussion !!!

If you have some long term discussion opened, please use forum, and NOT comment.

This because every user, like me, which has starred this esxtension will receive an email every time a comment is posted.

Please, stop...

#16610 report it
bandpay at 2014/03/10 11:29am
@AhmedK

Tell me that it's working, so we are all happy :)

#16607 report it
AhmedK at 2014/03/10 07:21am
@bandpay @muhammad RAfiq

hi im getting my json under the calender :) [{"title":"Meeting","start":"2014-03-09","color":"#CC0000","allDay":true,"url":"http:\/\/anyurl.com"},{"title":"Meeting reminder","start":"2014-03-10","end":"2014-03-11","color":"blue"}]

#16606 report it
Muhammad Rafiq at 2014/03/10 06:47am
Re: AhmedK

Greeting,

I spotted 2 problems First, it should be 'events' => Yii::app()->createUrl

Note the 's' in the event

2nd, when you use createUrl, you have to use the class name of the controller, i.e. if my controller is CalendarController, I will use Yii::app()->createUrl('calendar/CalendarEvents')

Note the calendar in createUrl is without the controller word.

I tried your code and dump it into my own program by fixing the 2 issues above and it works for me.

#16605 report it
bandpay at 2014/03/10 06:04am
@AhmedK

My friend, I told you to take it easy :)

'event'=>Yii::app()->createUrl('CalendrierController/CalendarEvents'),

it is 'events' not 'event'

and check in the accessRules if the CalendarEvents should be spelled "calendarEvents"

I have other problems which are as big for me as this one is for you :)

#16604 report it
AhmedK at 2014/03/10 05:00am
@bandpay @muhammad RAfiq

why when i put this 'events'=>$calendarEventsUrl, it says Undefined variable: calendarEventsUrl ???

#16603 report it
AhmedK at 2014/03/10 04:54am
@bandpay @muhammad RAfiq

hi guys !! ive made a calendar model and generated the crud !! ive puted the calendar view in the index of the calendar model !! ive puted the fonction action CalendarEvents in the controller !! but it's not working !!

public function accessRules()
    {
        return array(
            array('allow',  // allow all users to perform 'index' and 'view' actions
                'actions'=>array('index','view','CalendarEvents'),
                'users'=>array('*'),
            ),
            array('allow', // allow authenticated user to perform 'create' and 'update' actions
                'actions'=>array('create','update','admin','delete','CalendarEvents'),
                'users'=>array('@'),
            ),
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('admin','delete'),
                'users'=>array('admin'),
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }
public function actionCalendarEvents()
                {
 
                    $items[]=array(
                        'title'=>'Meeting',
                        'start'=>strtotime('2014-03-09'),
                        'color'=>'#CC0000',
                        'allDay'=>true,
                        'url'=>'http://anyurl.com'
                    );
                    $items[]=array(
                        'title'=>'Meeting reminder',
                        'start'=>strtotime('2014-03-10'),
                        'end'=>strtotime('2014-03-11'),
                        'color'=>'blue',
                    );
 
                    echo CJSON::encode($items);
                    Yii::app()->end();
                }
<?php
$this->widget('ext.EFullCalendar.EFullCalendar', array(
 
    'htmlOptions'=>array(
        // you can scale it down as well, try 80%
        'style'=>'width:100%'
    ),
    // FullCalendar's options.
    // Documentation available at
    // http://arshaw.com/fullcalendar/docs/
    'options'=>array(
        'header'=>array(
            'left'=>'prev,next',
            'center'=>'title',
            'right'=>'today,month,agendaWeek,agendaDay'
        ),
        'lazyFetching'=>true,
        //'events'=>CController::createUrl('CalendrierController/CalendarEvents'),
        //'events'=>$calendarEventsUrl,
        'event'=>Yii::app()->createUrl('CalendrierController/CalendarEvents'),
        // // action URL for dynamic events, or
       // 'events'=>'[{"title":"Meeting","start":"2014-03-09","color":"#CC0000","allDay":true,"url":"http:\/\/anyurl.com"}]',
 
        // pass array of events directly
        // event handling
        // mouseover for example
       // 'eventMouseover'=>new CJavaScriptExpression("js_function_callback"),
    )
));
?>
#16601 report it
bandpay at 2014/03/10 03:44am
@AhmedK :)

Don't panik Just try harder :)

#16600 report it
Muhammad Rafiq at 2014/03/10 02:38am
Re: AhmedK

2 things you should pay attention in your actionCalendarEvents()

  1. Make sure in your controller accessRules you have included the calendarEvents
  2. As I have mentioned in one of the replies, for the calendar data array to work, you need to supply date in PHP format. What I saw in the action below is that you use
'start'=>'2014-03-09',

try to change it to

'start'=>strtotime('2014-03-09'),

The same goes for the second array.

public function actionCalendarEvents()
                {
 
                    $items[]=array(
                        'title'=>'Meeting',
                        'start'=>'2014-03-09',
                        'color'=>'#CC0000',
                        'allDay'=>true,
                        'url'=>'http://anyurl.com'
                    );
                    $items[]=array(
                        'title'=>'Meeting reminder',
                        'start'=>'2014-03-10',
                        'end'=>'2014-03-11',
 
                        // can pass unix timestamp too
                        // 'start'=>time()
 
                        'color'=>'blue',
                    );
 
                    echo CJSON::encode($items);
                    Yii::app()->end();
                }
#16596 report it
AhmedK at 2014/03/09 06:44pm
heeeeeeeeeeellllllpppppppp !!

ive made this but nothing is working !! where must i display the calendar !! ive put it in the index view!!

<?php
$this->widget('ext.EFullCalendar.EFullCalendar', array(
    'lang'=>'fr',
   //'themeCssFile'=>'cupertino/theme.css',
    'htmlOptions'=>array(
        // you can scale it down as well, try 80%
        'style'=>'width:100%'
    ),
    // FullCalendar's options.
    // Documentation available at
    // http://arshaw.com/fullcalendar/docs/
 
    'options'=>array(
        'header'=>array(
            'left'=>'prev,next',
            'center'=>'title',
            'right'=>'today,month,agendaWeek,agendaDay'
        ),
        'lazyFetching'=>true,
        'events'=>CController::createUrl('CalendrierController/CalendarEvents'),
    )
));
?>

in my controller

public function actionCalendarEvents()
                {
 
                    $items[]=array(
                        'title'=>'Meeting',
                        'start'=>'2014-03-09',
                        'color'=>'#CC0000',
                        'allDay'=>true,
                        'url'=>'http://anyurl.com'
                    );
                    $items[]=array(
                        'title'=>'Meeting reminder',
                        'start'=>'2014-03-10',
                        'end'=>'2014-03-11',
 
                        // can pass unix timestamp too
                        // 'start'=>time()
 
                        'color'=>'blue',
                    );
 
                    echo CJSON::encode($items);
                    Yii::app()->end();
                }
#16571 report it
bandpay at 2014/03/06 09:18am
@AhmedK

Yes my firend. You have to populate an $events array with your data.
Create a function in your model that delivers the $events array

This code is for guidance purpose and is not of any other value.

public function fetchEvents(){
$events=[];
foreach($schedules as ........){
$events[] = [
    'id'=>'some_uniquid',
    'data'=>[
        'var1'=>'val1',
        'var2'=>'val2',
        'varn'=>'valn',
    ],
    'title'=>'Some_Title',
    'start'=>'a start date with this format Y-m-d H:i:s',
    'end'=>'an end date with this format Y-m-d H:i:s',
    'allDay'=>$isAllDay?true:false,
    'url'=>Yii::app()->createUrl('controller/action',['someVar'=>'someVal']),
];
}
return $events;
}
 
/*
call it in the controller/action which the AJAX call makes in the fullCalendar events function
 
then the $events must be json_encode()'d
*/
echo json_encode($model->fetchEvents());
exit;

I hope that it helps. :)

Leave a comment

Please to leave your comment.

Create extension