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 ;
}