PHP code example of funayaki / cakephp-calendar
1. Go to this page and download the library: Download funayaki/cakephp-calendar library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
funayaki / cakephp-calendar example snippets
$this->loadComponent('Calendar.Calendar');
$this->loadHelper('Calendar.Calendar');
/**
* @param string|null $year
* @param string|null $month
* @return void
*/
public function calendar($year = null, $month = null) {
$this->Calendar->init($year, $month);
// Fetch calendar items (like events, birthdays, ...)
$options = [
'year' => $this->Calendar->year(),
'month' => $this->Calendar->month(),
];
$events = $this->Events->find('calendar', $options);
$this->set(compact('events'));
}
foreach ($events as $event) {
$content = $this->Html->link($event->title, ['action' => 'view', $event->id]);
$this->Calendar->addRow($event->date, $content, ['class' => 'event']);
}
echo $this->Calendar->render();
echo $this->Html->link(
__('List {0}', __('Events')),
$this->Calendar->calendarUrlArray(['action' => 'index'], $event->date)
);
foreach ($events as $event) {
$content = ...;
$attr = [...];
$this->Calendar->addRowFromTo($event->beginning, $event->end, $content, $attr);
}
echo $this->Calendar->render();
$this->Calendar->init($year, $month, 5);