MAMP and Local Development PHP errors on install

I’m getting some errors after I tried to install a new theme on Kirby’s plainkit. I’m using MAMP locally and can access my panel fine but can’t get to anything on the front end. I’m getting an error in the theme’s menu.php file:

Whoops\Exception\ErrorException thrown with message “foreach() argument must be of type array|object, null given”

Stacktrace:
#23 Whoops\Exception\ErrorException in /Applications/MAMP/htdocs/kirby-art-slider/site/snippets/menu.php:19
#22 Whoops\Run:handleError in /Applications/MAMP/htdocs/kirby-art-slider/site/snippets/menu.php:19
#21 include in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Filesystem/F.php:410
#20 Kirby\Filesystem\F:loadIsolated in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Filesystem/F.php:387
#19 Kirby\Filesystem\F:load in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Toolkit/Tpl.php:36
#18 Kirby\Toolkit\Tpl:load in /Applications/MAMP/htdocs/kirby-art-slider/kirby/config/components.php:303
#17 Kirby\Cms\Core:{closure} in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Cms/App.php:1442
#16 Kirby\Cms\App:snippet in /Applications/MAMP/htdocs/kirby-art-slider/kirby/config/helpers.php:711
#15 snippet in /Applications/MAMP/htdocs/kirby-art-slider/site/snippets/header.php:24
#14 include in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Filesystem/F.php:410
#13 Kirby\Filesystem\F:loadIsolated in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Filesystem/F.php:387
#12 Kirby\Filesystem\F:load in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Toolkit/Tpl.php:36
#11 Kirby\Toolkit\Tpl:load in /Applications/MAMP/htdocs/kirby-art-slider/kirby/config/components.php:303
#10 Kirby\Cms\Core:{closure} in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Cms/App.php:1442
#9 Kirby\Cms\App:snippet in /Applications/MAMP/htdocs/kirby-art-slider/kirby/config/helpers.php:711
#8 snippet in /Applications/MAMP/htdocs/kirby-art-slider/site/templates/projects.php:1
#7 include in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Filesystem/F.php:410
#6 Kirby\Filesystem\F:loadIsolated in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Filesystem/F.php:387
#5 Kirby\Filesystem\F:load in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Toolkit/Tpl.php:36
#4 Kirby\Toolkit\Tpl:load in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Cms/Template.php:171
#3 Kirby\Cms\Template:render in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Cms/Page.php:1061
#2 Kirby\Cms\Page:render in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Cms/App.php:713
#1 Kirby\Cms\App:io in /Applications/MAMP/htdocs/kirby-art-slider/kirby/src/Cms/App.php:1086
#0 Kirby\Cms\App:render in /Applications/MAMP/htdocs/kirby-art-slider/index.php:5

I’ve tried troubleshooting the install and am fairly sure I did the htaccess and permissions correctly.

The theme is Slider following docs here.

What’s in that file (and particularly on line #19)?

Looks like there is an undefined variable in a foreach loop, we then also need the /site/templates/projects.php and the /site/snippets/header.php.

Also check if there is a /site/controllers/projects.php.

Thanks for replying.

The menu.php file is just markup for the navigation. This is the foreach loop throwing the error on line 19:

<?php foreach($pages->visible() as $item): ?>

So I think $pages is undefined unless $item is? I tried adding pages through the panel but no luck.

Then a call to menu.php throws an error in site/snippets/header.php:

<!doctype html>
<html lang="<?= site()->language() ? site()->language()->code() : 'en' ?>">
<head>

  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

  <title><?= $site->title()->html() ?> | <?= $page->title()->html() ?></title>
  <meta name="description" content="<?= $site->description()->html() ?>">

  <?= css('assets/css/bootstrap.min.css') ?>
  <?= css('assets/css/font-awesome.min.css') ?>
  <?= css('assets/css/index.css') ?>
  <style>
    body { font-family: <?php echo $site->font() ?>; }
  a, .navbar-default .navbar-brand, .navbar-default .navbar-nav>li>a, .icon, .icon .fa, .btn-link { color: <?php echo $site->primarycolor() ?>; }
  .icon { border-color: <?php echo $site->primarycolor() ?>; }
  a:hover, a:focus, a:active, a.active, .navbar-default .navbar-nav>li>a:focus, .navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-brand:focus, .navbar-default .navbar-brand:hover { color: <?php echo $site->secondarycolor() ?>; }
    <?php echo $site->css() ?>  
  </style>

</head>
<body>
<?php snippet('menu') ?>
<div class="container">

A call to header.php throws an error on line 1 here site/templates/projects.php:

<?php snippet('header') ?>

<?php $projects = $page->children()->listed();
if($projects->count() > 0): ?>
    <div class="col-sm-12">
        <div class="row grid article-feed">
          <?php foreach($projects as $project): ?>  
              <div class="grid-item col-xs-6 col-sm-4 col-md-4">
            <div id="<?php echo $project->uid() ?>" class="carousel slide" data-ride="caroussel">
              <div class="carousel-inner">
              <?php foreach($project->images() as $image): ?>
              <?php $first = $project->images()->first(); ?>
                      <div class="item<?php if($image == $first) echo ' active' ?>">
                        <a href="<?php echo $project->url() ?>">
                          <img class="img-responsive" src="<?php echo $image->url() ?>" alt="" />
                        </a>
                      </div>
              <?php endforeach ?>
              </div>
            </div>
            <span class="btn btn-link btn-xs text-uppercase"><?php echo $project->title() ?></span>
            <a class="btn btn-link btn-xs pull-right" href="#<?php echo $project->uid() ?>" data-slide="next"><span class="">></span></a>
            <a class="btn btn-link btn-xs pull-right" href="#<?php echo $project->uid() ?>" data-slide="prev"><span class=""><</span></a>
            </div>
          <?php endforeach ?>
        </div>
    </div>
<?php endif ?>

<?php snippet('footer') ?>

There is no /site/controllers/projects.php. I can’t figure out if this is an install issue or the theme’s code.

visible() is deprecated, should be listed() now. I think you bought a theme that wasn’t updated for some time. There are probably more such issues.

I’d contact the developer and ask for an update or a refund if this is not the only issue.

That was the issue, thanks! In case anyone else runs into this the Gumroad download version was incorrect contact the developer at oliviergassies@gmail.com for the correct version.

You can also change the listed() variable yourself but permissions may need changing on the Gumroad download.