Difference between #139 and #140 of
Yii v2 snippet guide

Revision #140 has been created by rackycz on Oct 6, 2019, 5:12:52 PM with the memo:

calendar
« previous (#139) next (#141) »

Changes

Title unchanged

Yii v2 snippet guide

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

tutorial,beginner,yii2

Content changed

[...]
}
```

**Tests - unit + opa**
---
... text ...

 
 
 
 
**Adding a google-like calendar**
 
---
 
 
I needed to show user a list of his events in a large calendar so I used library [fullcalendar](https://fullcalendar.io/).
 
 
Great demo which you can just copy and paste:
 
- https://fullcalendar.io/js/fullcalendar-3.0.0/demos/list-views.html
 
- ... just "view source" of the web and copy the js + html code, css and js files. Don't forget to use these files for example in your view like this:
 
 
```php
 
$this->registerCssFile('@web/css/fullcalendar/fullcalendar.css');
 
$this->registerCssFile('@web/css/fullcalendar/fullcalendar.print.css', ['media' => 'print']); 
 
 
$this->registerJsFile('@web/js/fullcalendar/moment.min.js', ['depends' => ['yii\web\JqueryAsset']]);
 
$this->registerJsFile('@web/js/fullcalendar/fullcalendar.min.js', ['depends' => ['yii\web\JqueryAsset']]);
 
 
// details here:
 
// https://www.yiiframework.com/doc/api/2.0/yii-web-view
 
```
 
 
... if you want to go pro, use NPM. The NPM way is described [here](https://fullcalendar.io/docs/getting-started).
 
 
API is  here:
 
https://fullcalendar.io/docs
 
... you can then enhace the calendar config from the example above
 
 
In order to make things work I had to force jQuery to be loaded before calendar scripts using file config/web.php like this
 
 
```php
 
   'components' => [
 
        
 
// ...
 

 
       'assetManager' => [
 
            'bundles' => [
 
                'yii\web\JqueryAsset' => [
 
                    'jsOptions' => [ 'position' => \yii\web\View::POS_HEAD ],
 
                ],
 
            ],
 
        ],
 
```
7 0
4 followers
Viewed: 259 304 times
Version: 2.0
Category: Tutorials
Written by: rackycz
Last updated by: rackycz
Created on: Sep 19, 2019
Last updated: 7 months ago
Update Article

Revisions

View all history