Breadcrumb show /all if there is only 1 item

I need some help with getting the breadcrumb menu fitting my needs. I want it to be:

For the projects page I want.

Project / All

And for project page.

Project / Project name

I have excluded home from the code.

<nav class="breadcrumb" role="navigation">
   <ul>
     <?php foreach($site->breadcrumb()->not('home') as $crumb): ?>
     <li>
       <a href="<?php echo $crumb->url() ?>">
         <?php echo html($crumb->title()) ?>
       </a>
     </li>
     <?php endforeach ?>
   </ul>
 </nav>

Anyone that can give me idea how to approach this? In simplest Kirby way. :slight_smile:

Found the solution and it was easy. :blush:


<nav class="breadcrumb" role="navigation">
   <ul>
     <?php $crumbs = $site->breadcrumb()->not('home') ?>
     <?php foreach($crumbs as $crumb): ?>
     <?php if($crumbs->count() <= 1): ?>
       <li>
         <a href="<?php echo $crumb->url() ?>">
           <?php echo html($crumb->title()) ?>
         </a>
       </li>
       <li>
         <a href="<?php echo $crumb->url() ?>">
           All
         </a>
       </li>
     <?php else: ?>
       <li>
         <a href="<?php echo $crumb->url() ?>">
           <?php echo html($crumb->title()) ?>
         </a>
       </li>
     <?php endif ?>
     <?php endforeach ?>
   </ul>
 </nav>