yii2fullcalendar
ve with latest full calendar release
JQuery Fullcalendar Yii2 擴充 JQuery 來自:http://arshaw.com/fullcalendar/ 版本 4.0.2 授權 MIT
JQuery 文件:http://arshaw.com/fullcalendar/docs/ Yii2 擴展,作者:[email protected]
可以在這裡找到一個小樣本:http://yii2fullcalendar.beeye.org
套件雖然是在 packagist.org 註冊的 - 所以你只需添加一行程式碼,讓它運行!
將以下行新增至您的composer.json require 部分:
"philippfrenzel/yii2fullcalendar" : " * " ,
或運行:
$ php composer.phar require philippfrenzel/yii2fullcalendar "*"
並確保您已全域安裝以下插件:
php Composer.phar 全域需要“fxp/composer-asset-plugin:~1.0”
17-04-2019 更新到最新的 4.0.2 穩定版本的庫 19-01-2017 更新為包括非標準字段 29-11-2014 更新到最新的 2.2.3 版本的庫
快速入門看起來像這樣:
$ events = array ();
//Testing
$ Event = new yii2fullcalendar models Event ();
$ Event -> id = 1 ;
$ Event -> title = ' Testing ' ;
$ Event -> start = date ( ' Y-m-dTH:i:sZ ' );
$ 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 yii2fullcalendar models Event ();
$ Event -> id = 2 ;
$ Event -> title = ' Testing ' ;
$ Event -> start = date ( ' Y-m-dTH:i:sZ ' , strtotime ( ' tomorrow 6am ' ));
$ events [] = $ Event ;
?>
<?= yii2fullcalendar yii2fullcalendar:: widget ( array (
' events ' => $ events ,
));
請注意,這只會查看事件,而沒有任何詳細視圖或添加新事件的選項......等等。
您可以透過非標準字段數組新增非標準字段,您可以為其傳遞任何鍵/值對,如事件字段文件中所述。
因此,使用上面的快速入門範例,您可以使用類似event.nonstandard.field1
和event.nonstandard.field2
符號在 JavaScript 中讀取field1
和fields2
。
如果你想使用 ajax 載入器,可能如下所示:
<?= yii2fullcalendar yii2fullcalendar:: widget ([
' options ' => [
' lang ' => ' de ' ,
//... more options to be defined here!
],
' events ' => Url:: to ([ ' /timetrack/default/jsoncalendar ' ])
]);
?>
在您引用的控制器內,操作應如下所示:
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 yii2fullcalendar models Event ();
$ Event -> id = $ time -> id ;
$ Event -> title = $ time -> categoryAsString ;
$ Event -> start = date ( ' Y-m-dTH:i:sZ ' , strtotime ( $ time -> date_start . ' ' . $ time -> time_start ));
$ Event -> end = date ( ' Y-m-dTH:i:sZ ' , strtotime ( $ time -> date_end . ' ' . $ time -> time_end ));
$ events [] = $ Event ;
}
return $ events ;
}