"Call to a member function gallery() on null" on page creation

Hey there!

Just got to work on a new Kirby project, set up my templates and blueprints as usual, but I’m getting this error whenever I try to create a new page in the backend:

Call to a member function gallery() on null

I must have messed up somewhere, but I don’t even know where to start looking.
I already tested removing content from the blueprint, but the only way Kirby will let me create the page is if the blueprint is entirely empty.

Thank your for any input!

Did you base this site on the starter kit? I think gallery() comes with it and uses a little plugin. Perhaps you deleted part of it and your now trying to use it?

@Weltverloren Is there any more information, like a stack trace? The only place in the Starterkit a gallery() method is called is in the gallery plugin:


Kirby::plugin('starterkit/gallery', [
    'hooks' => [
        'kirbytags:after' => function ($text, $data, $options) {

            if ($page = $data['parent']->gallery()->toPage()) {
                $gallery = snippet('gallery', ['gallery' => $page], true);
            } else {
                $gallery = '';

            return str_replace('{{ gallery }}', $gallery, $text);

But the error message means, that the page it is called on doesn’t exist. Although that shouldn’t happen if $page is false, hm…

Thank you both for the replies!

Since I was using a pre-edited kit, I just gave it another try with a fresh starter kit.

  1. I deleted the assets, content, blueprints, snippets and templates from it.
  2. I didn’t install any of my own assets or content yet for the test; I just copied over my blueprints, header/footer snippet and template.

I am still getting the same result.

I am not calling the gallery method anywhere. I even searched the entire project folder for use of the term “gallery”, which only comes up in “plugins\gallery\index.php”.

Try removing the plugin (delete the /site/plugins/gallery) folder to see if you still get the error.

1 Like