Versatile Article Layouts

template

#1

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:


#2

The builder plugin would be the way to go.


#3

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!!!


#4

@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


#5

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


#6

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()).


#7

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


#8

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.