Versatile Article Layouts

I’m wondering the best way to create the admin side for versatile layouts that the user can choose what to have and where depending on the content. I’m not sure of the best way to approach this so if anyone has managed something similar or knows a good way, I would appreciate some advice.

Thank you

This is the example:

The builder plugin would be the way to go.

Oh wow! Thank you @texnixe I’m so glad I asked rather than trying to create something half arsed now :slight_smile: Thank you so much and massive kudos to @timoetting the creator!!!

1 Like

@texnixe & @timoetting - Just a quick cry for help. I can’t get the content to load in the webpage.

<?php snippet('head') ?>

<div class="container <?= $page->slug() ?>" >
  <div class="module nopad">
    <?php snippet('header') ?>
    <main>
      <header class="intro">
        <h1><?= $page->title() ?></h1>
      </header>
      <div>
      <?php foreach($page->builder()->toBuilderBlocks() as $block): ?>
        <?php snippet('blocks/' . $block->_key(), array('data' => $block)) ?>
      <?php endforeach ?>
      </div>
    </main>
  </div>
</div>

<?php snippet('footer') ?>  

It loads all the content apart from the content in the foreach

Do the snippets exist in the right place and are their names the same as the ones you put into your blueprint?

I think you should check your blueprint .yml file for the name of the builder field. When I first used kirby-builder, I followed the example code and did not notice the field is named “mybuilder”, but the function in template looks for “builder” ($page->builder()->toBuilderBlocks()).

That did the trick @czJonny - Thank you and thank you @texnixe and @timoetting :slight_smile:

I followed the example code and did not notice the field is named “mybuilder”, but the function in template looks for “builder” ($page-> builder() ->toBuilderBlocks()).

Yeah, that’s definitely confusing. I changed it in the ReadMe.

1 Like