1
0
Fork 0
web-jbeyerstedt/modules/columns-plugin/index.php

29 lines
908 B
PHP
Raw Normal View History

2021-01-24 17:05:39 +00:00
<?php
# from https://getkirby.com/docs/cookbook/extensions/columns-in-kirbytext
# copied at 2021-01-23
Kirby::plugin('kirby/columns', [
'hooks' => [
'kirbytags:before' => function ($text, array $data = []) {
$text = preg_replace_callback('!\(columns(…|\.{3})\)(.*?)\((…|\.{3})columns\)!is', function($matches) use($text, $data) {
$columns = preg_split('!(\n|\r\n)\+{4}\s+(\n|\r\n)!', $matches[2]);
$html = [];
$classItem = $this->option('kirby.columns.item', 'column');
$classContainer = $this->option('kirby.columns.container', 'columns');
foreach ($columns as $column) {
$html[] = '<div class="' . $classItem . '">' . $this->kirbytext($column, $data) . '</div>';
}
return '<div class="' . $classContainer . '">' . implode($html) . '</div>';
}, $text);
return $text;
}
]
]);