Kirby Builder multiple sections and call issue

Hi Kirby forum users!

I’m trying to use Tim Oetting’s Kirby Builder plugin ( https://github.com/TimOetting/kirby-list-field ) to create multiple sections with separate builders and nothing seems to load. Perhaps I’ve missed something about the limitations of the plugin or I’m implementing it wrong? Any help would be much appreciated.

My blueprint for the page looks like this

fields:
  title:
    label: Title
    type: title

  details:
    label: Key Details
    type: textarea

  intro:
    label: Introduction
    type: textarea

  employmentSection:
    label: Employment
    type: builder
    fieldsets:
      employment:
        label: Experience
        fields:
          employer:
            label: Employer
            type: text
            width: 3/4
          year:
            label: Year
            type: text
            width: 1/4
          based:
            label: Based
            type: text
            width: 1/2
          position:
            label: Position
            type: text
            width: 1/2
          description:
            label: Description
            type: textarea

  volunteeringSection:
    label: Volunteering
    type: builder
    fieldsets:
      volunteering:
        label: Volunteering
        fields:
          organisation:
            label: Organisation
            type: text
            width: 3/4
          year:
            label: Year
            type: text
            width: 1/4

  educationSection:
    label: Education
    type: builder
    fieldsets:
      education:
        label: Education
        fields:
          qualification:
            label: Qualification
            type: text
            width: 3/4
          year:
            label: Year
            type: text
            width: 1/4
          university:
            label: University
            type: text

I’m calling it in the template like this:

<div class="practice-block">
    <h3>Experience:</h3>
    <?php foreach($page->builder()->employmentSection()->toStructure() as $section): ?>
        <?php snippet('sections/' . $section->_fieldset(), array('data' => $section)) ?>
    <?php endforeach ?>
</div>

And the snippet looks like this:

<section class="experience">
    <div class="clearfix see-also-li margin-bottom-lh">
        <h1 class="inline-block-l"><?php echo $data->employer()->kt() ?></h1><h1 class="inline-block-r"><?= $data->year() ?></h1>
    </div>
    <table>
      <tr>
        <td>Based:</td>
        <td><?= $data->based() ?></td>
      </tr>
      <tr>
        <td>Position:</td>
        <td><?= $data->position() ?></td>
      </tr>
    </table>
    <p class='fl-indent'><?= $data->description() ?></p>
</section>

This is just an example of the ‘employmentSection’. What am I missing here?

This line:

should be:

<?php foreach($page->employmentSection()->toStructure() as $section): ?>

You are using two consecutive field names here.

If you have only one fieldset per builder field, you might as well use the built-in structure field. Or include all three sections in one builder field.

If you continue to have problems, you might want to try and change your camelCase field to using underscores or all lowercase (I think we had some environments where camelCase was causing issues).

@texnixe you are my hero! Thanks for all your help, it’s much appreciated!

1 Like