New user, problem after installation

Hi everybody,

I run Kirby on an Apache via XAMPP and the installation seems to work. I can use the /my-site/panel and created some home, error and searchpages after editing some of the site configs.

Here comes the issue:
When I try to visit the page /my-site/there’s an error and it won’t load. Using the debug mode I am getting an

ErrorException (E_NOTICE)
Undefined variable: class

in \site\snippets\content.php line 1 which reads <article class="margin-bottom-2 <?php echo $class ?>">

I already tried to reinstall everything (aka deleted the whole /kirby/*path and c&p’ed it back from the downloaded zip.

edit: I am using v2.5.12 on a Apache/2.4.37 (Win32) OpenSSL/1.1.1a PHP/7.3.0

Any clues? Thanks for your time.

Where is the variable defined? In the template where you call the snippet? You have to pass it down to the snippet to be able to use it there.

Hi Sonja,

I have no idea where it is defined, I did not create any files so far and did not change any code, other than turning off and on the debug mode. Isn’t it supposed to work without changing around stuff?
I am using a template, could that cause the issue?


You mean a third party theme? Which one?

This line:

<?php echo $class ?>

is definitely not part of a standard Kirby Starterkit.

Maybe you can post the template where the content.php snippet is used.

Yes, a third party theme. It’s called HyperKirby. Sorry, I was not thinking about that this could be the issue. I contacted the author, since it’s a paid service.

It is called from kirby.php:

 return $this->;template($page, $data);
 public function template(Page $page, $data = array()) {
     return $this->component('template')->render($page, $data);

it’s loaded in kirby\component\template.php

$result = tpl::load($file, null, $return);

Quick update in case anyone else reads about it here:

Removing E_NOTICE error handling from PHP’s settings (via php.ini) solved it. The issue itself is still there, but it is reported and the author of the above mentioned theme is going to fix it.

This is caused by error E_NOTICE triggering an error on uninitiated variables:

  1. You can turn error E_NOTICE off (optional)
  2. You can initiate variables as empty string $var = '' or null $var = null (depending on their nature) until you assign a proper value later in your code
  3. Being a third party theme, contacting the author directly would get you a release update with a proper fix

This is especially true when passing variables to snippets:

1 Like

That’s not really a recommendable solution, because you should really be made aware of undefined variables.

Definitely good advice. I’m sticking to it from now on.