microman/kirby-grid-blocks

Use the layouts field as block

Installs: 1 536

Dependents: 0

Suggesters: 0

Security: 0

Stars: 30

Watchers: 4

Forks: 1

Open Issues: 0

Type:kirby-plugin

1.0.0 2021-10-05 10:11 UTC

This package is auto-updated.

Last update: 2024-04-18 13:54:16 UTC


README

Overview

With this plugin you can use layouts right within any blocks field! 🤗

Its most basic use-case is shown in the following screenshot:

Grid block

This plugin is free to use and published under the MIT license. If you use this plugin for commercial purposes and you want to show your appreciation, don't hesitate to support me with a donation or purchasing your license(s) through my affiliate link.

Installation

Download and copy this repository to your plugin folder: /site/plugins/

Composer

composer require microman/kirby-grid-blocks

Block field usage in the frontend

<?php foreach ($page->myGrid()->toBlocks() as $grid): ?>
  <h2><?= $grid->title() ?></h2>

  <!--
  Customize the Grid-Block and use any custom fields:
  <?= $grid->yourCustomFields() ?>
  -->

  <?= $grid ?>
<?php endforeach ?>

Customization

Grid block

Simply copy the main grid.yml from site/plugins/grid-block/blueprints/blocks to your project's site/blueprints/blocks folder. The latter one will be used by Kirby instead of the one provided by the plugin.

Of course, you can customize it to your needs:

textContent:
  label: Content with Text
  type: blocks
  fieldsets:
    grid:
      extends: blocks/grid
      fields:
        grid:
          layouts:
            - "1/1"
          fieldsets:
            - heading
            - text
        title:
          label: Title
        margin:
          type: range
          after: px
          default: "5"
          min: 0
          max: 200

You'll find the description for this example blueprint in the screenshot above.

Snippet

Copy the block snippet grid.php from site/plugins/grid-block/snippets/blocks to your project's site/snippets/blocks folder. The latter one will be used by Kirby instead of the one provided by the plugin.

Licence

MIT

Buy me a ☕️

Get a Kirby-license(s) 💳