Calendar plugin not rendering pages

Dear community,

as I am a noob and completely new to Kirby, this question might seem stupid to you. However, your help is highly appreciated here:

I am trying to get the calendar plugin to work. I have - to my understanding - stuck exactly to the manual, copied the files into the /site/snippets and /site/template folders, configured and activated languages. In the panel, I can edit events nicely. However, the events page is not being rendered. Instead, I see a blank page when I open the url in a browser.

Any ideas, hints and help is highly appreciated!

Could you pls. turn on debugging in your config.php and then check your error messages:

c::set('debug', true);

It would also help if you posted your code. Thank you.

Thanks for the quick reply!

I’ve turned debug mode on but no error messages showed up.

These are my files:

/content/events/calendar.de.txt

Title: Events

----

Calendar: 

- 
  summary: My event
  description: A super cool event
  _begin_date: 2016-05-22
  _begin_time: 10:00
  _end_date: 2016-05-22
  _end_time: 11:00

/site/languages/de.php

<?php

l::set('calendar-time-format', '%d');
l::set('calendar-full-time-format', '%d %X');
l::set('calendar-month-format', '%B %Y');
l::set('calendar-no-entry', 'Zur Zeit gibt es keine Events.');

l::set('date', 'Datum');
l::set('to', 'bis');

l::set('title', 'Titel');
l::set('description', 'Beschreibung');

/site/plugins/calendar/calendar.php

<?php

if (!class_exists('Calendar'))  require_once('lib/Calendar.php');
if (!class_exists('Event')) require_once('lib/Event.php');

function calendar($events = array()) {
	try {
		return new Calendar($events);
	} catch (Exception $e) {
		print "<strong>The calendar plugin threw an error</strong><br>" .
			$e->getMessage();
	}
}

/site/templates/calendar-div.php

<?php
	$tmpDate = getdate(0);
	$currentDate = getdate();
?>
<section class="calendar">

<?php
	if (!$calendar->getAllEvents()):
		echo l::get('calendar-no-entry');
	else:
?>
	<div class="row head">
		<div class="item"><?php echo l::get('date'); ?></div>
<?php foreach ($fields as $field): ?>
		<div class="item"><?php echo $field; ?></div>
<?php endforeach; ?>
	</div>
<?php foreach ($calendar->getAllEvents() as $event):
		$date = $event->getBeginDate();
?>
<?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(l::get('calendar-month-format'), $date[0]); ?></div>
	</div>
<?php 	endif; ?>
	<div class="row event<?php e($event->isPast(), ' past'); ?>">
		<div class="item date"><?php
				echo $event->getBeginHtml();
				if ($event->hasEnd()) {
					echo ' '.l::get('to').' '.$event->getEndHtml();
				}
		?></div>
<?php 	foreach ($fields as $key => $value): ?>
		<div class="item"><?php echo $event->getField($key); ?></div>
<?php 	endforeach; ?>
	</div>
<?php $tmpDate = $date; ?>
<?php endforeach; ?>

<?php endif; ?>
</section>

/site/templates/calendar-ical.php

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//<?php echo $site->url(); ?>//Kirby Calendar Plugin//<?php echo str::upper($site->language()->code()); ?> 
METHOD:PUBLISH
<?php foreach ($calendar->getAllEvents() as $event): ?>
BEGIN:VEVENT
DTSTART:<?php echo gmdate('Ymd\THis\Z', $event->getBeginTimestamp()); ?> 
DTEND:<?php echo gmdate('Ymd\THis\Z', $event->getEndTimestamp()); ?> 
SUMMARY:<?php echo $event->getField('summary') ?> 
DESCRIPTION:<?php echo $event->getField('description') ?> 
LOCATION:<?php echo $event->getField('location') ?> 
END:VEVENT
<?php endforeach; ?>
END:VCALENDAR

/site/templates/calendar-table.php

<?php
	$tmpDate = getdate(0);
	$currentDate = getdate();
?>

<table class="calendar">

<?php if (!$calendar->getAllEvents()): ?>

	<tr><td><?php echo l::get('calendar-no-entry'); ?></td></tr>

<?php else: ?>

	<thead>
		<tr>
			<th><?php echo l::get('date'); ?></th>
<?php foreach ($fields as $field): ?>
			<th><?php echo $field; ?></th>
<?php endforeach; ?>
		</tr>
	</thead>
	<tbody>
<?php foreach ($calendar->getAllEvents() as $event):
		$date = $event->getBeginDate();
?>
<?php 	if ($tmpDate['mon'] < $date['mon'] || $tmpDate['year'] < $date['year']): ?>
		<tr class="month<?php e($date['mon'] < $currentDate['mon'] or $date['year'] < $currentDate['year'], ' past'); ?>">
			<td colspan="<?php echo count($fields)+1; ?>"><?php echo strftime(l::get('calendar-month-format'), $date[0]); ?></td>
		</tr>
<?php 	endif; ?>
		<tr class="event<?php e($event->isPast(), ' past'); ?>">
			<td><?php
				echo $event->getBeginHtml();
				if ($event->hasEnd()) {
					echo ' '.l::get('to').' '.$event->getEndHtml();
				}
			?></td>
<?php 	foreach ($fields as $key => $value): ?>
			<td><?php echo $event->getField($key); ?></td>
<?php 	endforeach; ?>
		</tr>
<?php $tmpDate = $date; ?>
<?php endforeach; ?>
	</tbody>

<?php endif; ?>
</table>

/site/templates/calendar-teaser.php

<ul class="teaser">
<?php
	foreach ($calendar->getEvents() as $event):
		if (--$items < 0) break;
?>
	<li><strong><?php echo $event->getBeginHtml(); ?></strong><?php
		foreach ($fields as $key => $value) {
			echo ' '.$event->getField($key);
		}
	?></li>
<?php endforeach; ?>
</ul>

/site/templates/calendar.php

<?php $calendar = calendar($page->calendar()->yaml()); ?>

Is that all you’ve got in your calendar.php template? You need to include one of the snippets provided by the plugin or create your own. Currently, all you do is to define the calendar object.

For example, if you want to use the table snippet, you have to add this code in your template:

<?php
    snippet('calendar-table', array(
        'calendar'  => $calendar,
        'fields'        => array(
            'summary'       => l::get('title'),
            'description'   => l::get('description')
        )
    ));
?>

It is not enough to just add it to the snippets folder.

Ah, perfect, thanks for the hint. I took default.php as template and added the snipplet in the following way:

/site/templates/calendar.php

<?php snippet('header') ?>
<?php $calendar = calendar($page->calendar()->yaml()); ?>
  <div class="wrap content">

    <?php snippet('sidebar') ?>

    <section id="main" class="main-content" role="main">
      <?php     snippet('calendar-table', array(
        'calendar'  => $calendar,
        'fields'        => array(
            'summary'       => l::get('title'),
            'description'   => l::get('description')
        )
    ));
 ?>
    </section>

  </div><!-- /.wrap content -->

<?php snippet('footer') ?>
</div> <!-- /.container -->

It is not rendered beautiful but I think I can do this later by hand.