Newbie snippet question

Hi all -

Please bare with me, but I’m trying to get my first Kirby site running and am hitting what is probably a simple issue.

I’ve used the ‘starter kit’ and am trying to create a ‘Case Studies’ category and page. I’ve managed to do it, but I can’t loop any subpages on the case study template landing page.

I’ve used the the ‘showcase.php’ snippet that came with starter kit, but have changed it to be:

<?php

$casestudies = page('casestudies')->children()->visible();

if(isset($limit)) $casestudies = $casestudies->limit($limit);

?>

<ul class="showcase grid gutter-1">

  <?php foreach($casestudies as $casestudy): ?>

    <li class="showcase-item column">
        <a href="<?= $casestudy->url() ?>" class="showcase-link">
          <?php if($image = $casestudy->images()->sortBy('sort', 'asc')->first()): $thumb = $image->crop(600, 600); ?>
            <img src="<?= $thumb->url() ?>" alt="Thumbnail for <?= $casestudy->title()->html() ?>" class="showcase-image" />
          <?php endif ?>
          <div class="showcase-caption">
            <h3 class="showcase-title"><?= $casestudy->title()->html() ?></h3>
          </div>
        </a>
    </li>

  <?php endforeach ?>

</ul>

But nothing is showing. Please note that I’ve also removed dashes in ‘case-study’ in case that was causing an issue, and have tried using it as all one word.

What exactly are the $casestudy and $casetudies variables in the snippet referencing? If I need to paste any other code or show folder structure please let me know.

Thanks for you patience!

What is the name of the page folder? Is it called “casestudies” or “case-studies” or “CaseStudies”? Are the children visible?

$casestudies is the collection you define with $casestudies = page('casestudies')->children()->visible();

$casestudy is a new variable that you assign as a references to a single item of the collection within the foreach loop.

They weren’t visible! What a muppet! Thanks so much :slight_smile: