Calendar Plugin not showing events

Hi there!

I’m trying to get this Calendar Plugin to work and I feel i’m almost there but currently I’m stuck.

Somehow the content I provide through the calendar Blueprint doesn’t show on the website. It displays There currently are no events. which means it works, but not as intended I guess :smiley:

  • I know I have installed the Plugin correctly
  • I included <?php date_default_timezone_set('Europe/Berlin'); ?> in the head snippet
  • I set up a blueprint for the calendar events (see below)
  • I referred to the calendar snippet and included the calendar object (see below)

What am I missing? Any help would be greatly appreciated
Cheers

Calendar template

<?php snippet('header') ?>
  <?php snippet('intro') ?>
  <?php $calendar = new Mzur\KirbyCalendar\Calendar($page->calendar()->yaml()); ?>
  
  <?php
   snippet('calendar-div', [
      'calendar' => $calendar,
      'fields' => [
         'summary' => t('title'),
         'description' => t('description'),
         '_begin_date' => t('Start date')
      ]
   ]);
?>
  
<?php snippet('footer') ?>

Blueprint

title: Events
fields:
  title:
    label: Title
    type:  text
    readonly: true
  events:
    label: Events
    type: structure
    sortBy: _begin_date asc
    fields:
      _begin_date:
        label: Start date
        type: date
        display: DD.MM.YYYY
        required: true
      _begin_time:
        label: Start time
        type: time
        interval: 15
        required: false
      _end_date:
        label: End date
        type: date
        display: DD.MM.YYYY
        required: false
      _end_time:
        label: End time
        type: time
        interval: 15
        required: false
      summary:
        label: Title
        type: text
        required: true
      description:
        label: Description
        type: text
        required: false

Here you call $page->calendar()…

Your field is called events, though!

omg, good catch! :sweat_smile: thanks a lot

I have a followup question however. Now I get this error:

Function strftime() is deprecated

<?php     if ($tmpDate['mon'] < $date['mon'] || $tmpDate['year'] < $date['year']): ?>
    <div class="row month<?php e($date['mon'] < $currentDate['mon'] or $date['year'] < $currentDate['year'], ' past'); ?>">
        <div class="item"><?php echo strftime(t('calendar-month-format'), $date[0]); ?></div>
    </div>
<?php     endif; ?>

I guess this has something to do with PHP 8.1? Not quite sure how to deal with that.

Okay, yes with PHP 8.1 strftime and gmstrftime functions are deprecated.
But I found a solution allowing me to keep strftime. I implemented this package and it provides a cross-platform alternative to strftime() for when it will be removed from PHP.

The better solution would probably be to use IntlDateFormatter::format but I’m not sure how to use this without messing up the caldendar plugin :smiley:

Anyway, it seems to work for now. Thanks again!

What I’d so instead is overwrite the relevant snippet in your site/snippets folder, change the date handler to intl in the config, and adapt the date formats in the snippet accordingly.

Date format strings for the intl handler: Formatting Dates and Times | ICU Documentation