Having issues specifying subpages of subpage

I am building out an about page for a website. The ABOUT page has a subpages ( TEAM ) which have their own subpages (FEATURE) .

I would like each TEAM subpage to have it’s own container with it’s own FEATURE subpages displayed inside of them. I know there’s a way to call all of the grandchildren of the About page using Kirby but how would I specify to only call specific subpages of each for each section.

Here is my code thus far. I’m modifying the about template of the kirby starter kit. I get no error code but nothing shows up at all.

About.PHP

   <?php foreach($page->children()->visible() as $feature): ?>
      <section class="team wrap wide">

        <h2><?= $feature->title()->html() ?></h2>


        <ul class="team-list grid gutter-1">
          <?php foreach($feature->children()->visible() as $member): ?>
            <li class="team-item column">

              <figure class="team-portrait">
               <img src="<?= $member->image()->url() ?>" alt="Portrait of <?= $member->title()->html() ?> " />
              </figure>

              <div class="team-info">
                <h3 class="team-name"><?= $member->title()->html() ?></h3>
                <div class="team-about text">
                  <?= $member->about()->kirbytext() ?>
                </div>
              </div>
            </li>
          <?php endforeach ?>
        </ul>

      </section>
<?php endforeach ?>

about.yml

title: About

pages:
  template: team
  num: zero

files: false

options: 
  template: false  
  status: false  
  
fields:
  title:
    label: Title
    type: title
    
  intro:
    label: Intro
    type: textarea
    
  text:
    label: Text
    type: textarea

team.yml

title: Team Member

pages: true
  template: feature
  num: zero

files: false

icon: user

preview: parent

fields:
  title:
    label: Name
    type: title

  about:
    label: About
    type: textarea

Feature.yml

title: Feature

pages: false
template: feature

icon: user

preview: parent

fields:
  title:
    label: Name
    type: title

  about:
    label: About
    type: textarea

—K

Hi, one question ¿are your feature pages actually visible? and… in the about.yml you posted, there is another page definition for ‘Team member’ ?

1 Like

Hi there,
Thanks that was my fault. The pages were still invisible which was causing issues. They are working now!

Please note that the above code can break your site if there is no image.

<?php if($image = $member->image()): ?>
  <figure class="team-portrait">
    <img src="<?= $image->url() ?>" alt="Portrait of <?= $member->title()->html() ?> " />
  </figure>
<?php endif ?>

Ah thanks. I would have to use an $field->isNotEmpty followed by the image code correct?

No, it is not really important if the field is empty or not, or rather, <?php if($image = $member->image()): ?> will return false if the field is empty or if the image does not exist, so the additional check for the empty field is not really necessary.