FullCalendar


(Damian Lalewicz) #1

Have anyone ever had to do with FullCalendar extension? If so, anyone perhaps knows how to add second event.

The following code can’t add second event.


<?php 

$this->widget('application.extensions.fullcalendar.FullcalendarGraphWidget', 

    array(

        'data'=>array(

    		array(

    			'id'=>'11',

                'title'=> 'All Day Event',

                'start'=> date('2010-08-21'),

    			'end'=> date('2010-08-23'),

		    ),

		    array(

    			'id'=>'15',

                'title'=> 'Big Day',

                'start'=> date('2010-08-27'),

		    )

        ),

        'options'=>array(

            'editable'=>true,

        ),

        'htmlOptions'=>array(

               'style'=>'width:800px;margin: 0 auto;'

        ),

    )

);

?>




(Damian Lalewicz) #2

I realize that no one was occupied with it.


(Thyseus) #3

I am.

You need to fix one line in the FullCalendar Widget.

Open the FullCalendarGraphWidget.php and change line 25 to:

$encodeoptions=CJavaScript::encode($this->options+array(‘events’=>$this->data));

good luck :)


(Damian Lalewicz) #4

It works. Thanks :)


(Vincent Qiang Dong) #5

Yeah, it works fine.


(Vincent Qiang Dong) #6

According this fix.

/*

$encodeoptions=CJavaScript::encode($this->options+array(‘events’=>$this->data));

*/

You can get a full calendar with event adding/dragging by these code.

<?php

	&#036;this-&gt;widget('application.extensions.fullcalendar.FullcalendarGraphWidget', 


    	array(


	        'data'=&gt;array(


    	        array(


        	        'title'=&gt; 'All Day Event',


	                'start'=&gt; date('2010-09-01'),


                    'end'=&gt; date('2010-09-02'),


    	        ),


                array(


	                'title'=&gt; 'test',


	                'start'=&gt; date('2010-09-05'),


                    'end'=&gt; date('2010-09-06'),


                )


	        ),


	        'options'=&gt;array(


	            'editable'=&gt;true,


	            'header' =&gt; array(


        	        'left' =&gt; 'prev,next today',


        	        'right' =&gt; 'month,agendaWeek,agendaDay',


        	        'center' =&gt; 'title',


    	        ),


    	        'selectable' =&gt; true,


    	        'selectHelper' =&gt; true,


    	        'select' =&gt; &quot;js:function(start, end, allDay) {


    	            var title = prompt('Event Title:');


			        if (title) {


				        calendar.fullCalendar('renderEvent',


						    {


								title: title,


								start: start,


								end: end,


								allDay: allDay


							},


							true // make the event 'stick'


						);


					}





					calendar.fullCalendar('unselect');


    	        }&quot;


	        ),


	        'htmlOptions'=&gt;array(


	               'style'=&gt;'width:720px;margin: 0 auto;'


	        ),


		)


	);

?>


(Damian Lalewicz) #7

Also, thanks. Certainly be helpful :)


(Damian Lalewicz) #8

However, when you select and add an event title will not be added :unsure:

And one more question. How to specify the exact time?


(Vincent Qiang Dong) #9

For question 1:

This is just a demo about front-end, if you want to save you event then you need Ajax call and some PHP code to save the event object.

For question 2:

Below is a piece of code that can specify the exact time.

array(

‘title’=> ‘test’,

‘start’=> date(‘2010-09-05 13:00:30’),

‘end’=> date(‘2010-09-05 14:30:30’),

‘allDay’ => false

)

The start and end attributes can be also a UNIX timestamp. But allDay attributes must be false if you want specify the exact time.


(Damian Lalewicz) #10

Although I have tested so many combinations something like that didn’t enter my mind :) Thanks

With regard to the first question I know that it is necessary to combain these two technologies to save.

However concerning displaying itself - it can’t show what you would like to add, i.e. ‘window’ to add title an event emerges but the event after addition doesn’t show itself even temporarily.

My code:


$this->widget('application.extensions.fullcalendar.FullcalendarGraphWidget', 

    array(

        'data'=>array(

			array(

				'title'=> 'test',

				'start'=> date('2010-09-02 06:30'),

				'end'=> date('2010-09-02 07:30'),

				'allDay'=> false

			)

        ),

        'options'=>array(

        	'theme'=> true,

            'editable'=>true,

        	'header' => array(

				'left' => 'prev,next today title',

				'right' => 'month,agendaWeek,agendaDay',

				//'center' => 'title',

			),

			'selectable' => true,

			'selectHelper' => true,

			'select' => "js:function(start, end, allDay) {

				var title = prompt('Event Title:');

				if (title) {

					calendar.fullCalendar('renderEvent',{

						title: title,

						start: start,

						end: end,

						allDay: allDay

					},

					true // make the event 'stick'

					);

				}

				calendar.fullCalendar('unselect');

			}"

		),

        'htmlOptions'=>array(

               'style'=>'width:800px;margin: 0 auto;'

        ),

    )

);


(Damian Lalewicz) #11

This:


$ ('# Calendar'). FullCalendar ((

is likely to be recorded like this:


'Options' => array (

I have a question how to transform this statement in php


var calendar = $ ('# calendar'). fullCalendar ((

because without this probably does not want to dynamically add events.


(Vincent Qiang Dong) #12

Sorry, late to comment

For my mistake I forgot the important code. According to the above code you should change the code “Yii::app()->getClientScript()->registerScript(CLASS.’#’.$id,”$(’#$id’).fullCalendar($encodeoptions);");" in FullcalendarGraphWidget.php to “Yii::app()->getClientScript()->registerScript(CLASS.’#’.$id,“var calendar=$(’#$id’).fullCalendar($encodeoptions);”);”

If done the code can work well.

Enjoy yourself and good luck.


(Damian Lalewicz) #13

It works. Thanks :)


(Rsvana) #14

Thank you so much Bulwaria for posting this example! It was the final piece of help I needed to get the calendar to work. Thanks!


(Closerwalk) #15

How do you add hyperlinks to the events. Like the one on the Yii extension page demos an event click her for facebook?


(Closerwalk) #16

‘url’=>‘http://google.com

for anyone who wants to know.

Figured it out.


(Utalha) #17

How can I change color of different events ?


(Pellicanipasquale) #18

eventBackgroundColor


(Deepesh Saini111) #19

It’s really works. Thanks…


(Pujarishreyas15) #20

Hi! I am using the fullcalendar widget updated to version 1.5.3 & am using ajax call for "select" to save an event. The created event is getting saved in database but it is not sticking to the calendar when created. "renderEvent" is not working for me & so is its stick parameter. The events are displayed on reloading the page. But I want to stick the events to the calendar when they are created.

Also, in the week view when i click on any time slot, the slot gets selected with certain delay i.e. if I click on 6:00 am then 7:30 am slot gets selected.

Any help will be appreciated. Thanks in advance.