Hello Colorlib Support Team,
I am Fatih.
I am using the Calendar-20 provided by Colorlib and encountered an issue. The events (fetched from the events.php
file) are not being displayed when the calendar is opened by default.
Details:
- I am using Calendar-20.
- I have set the
defaultDate
property of the calendar to today’s date. - I am fetching event data from the
events.php
file.
events.php
<?php
global $wpdb;
$events = array();
// Determination of all annual leave approved records
$query = "SELECT * FROM {$wpdb->prefix}izin_bilgileri WHERE `izin_turu` = 'Yıllık İzin' AND `onay_durumu` = 'Onaylandı';";
$results = $wpdb->get_results($query, ARRAY_A);
if ($results) {
foreach ($results as $row) {
// Using user_id to get username and lastname
$user_info = get_userdata($row['user_id']);
$user_name = $user_info->user_login;
$events[] = array(
'title' => $user_name,
'start' => $row['baslangic_tarihi'] . ' ' . $row['baslangic_saati'],
'end' => $row['bitis_tarihi'] . ' ' . $row['bitis_saati']
);
}
}
echo json_encode($events);
?>
index.html
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'interaction', 'dayGrid', 'timeGrid', 'list' ],
height: 'parent',
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
defaultView: 'dayGridMonth',
defaultDate: new Date(),
navLinks: true,
editable: true,
eventLimit: true,
events: 'events.php'
});
calendar.render();
});
</script>
Thank you for your assistance and support.