Skip to content

Block snippets

Bastian Allgeier edited this page Aug 6, 2019 · 4 revisions

You can customize the HTML output of each block individually with custom block snippets.

All snippets for editor blocks must be located in site/snippets/editor. If the folder does not exist yet, just create it manually.

Block snippet names

  • /site/snippets/editor/blockquote.php
  • /site/snippets/editor/code.php
  • /site/snippets/editor/h1.php
  • /site/snippets/editor/h2.php
  • /site/snippets/editor/h3.php
  • /site/snippets/editor/hr.php
  • /site/snippets/editor/image.php
  • /site/snippets/editor/kirbytext.php
  • /site/snippets/editor/ol.php
  • /site/snippets/editor/paragraph.php
  • /site/snippets/editor/ul.php
  • /site/snippets/editor/video.php

Available variables

Each block snippet receives a number of default block variables that you can use to create the HTML for the block.

$block

The entire block object

$content

The main content of the block is a field object and has full access to all field methods

$attrs

An object of all available attributes. All attributes are field objects and have full access to all field methods. You can fetch non existing attributes without risk and check with isEmpty or isNotEmpty if they exist or have some content

$prev

The previous block object if available

$next

The next block object if available

You can’t perform that action at this time.