KIRBY 2 ONLY. No plans for K3 version yet. Table field for Kirby CMS.
Kirby tablex - simple table field for Kirby CMS. Advice, features and sugestions welcome.
As any field in blueprint:
table:
label: table
type: tablex
options:
maxColumns: 10
minColumns: 3
header: false
Options are not required. Defaults are:
maxColumns: 10
minColumns: 1
header: false
Content is then structured as regular yaml arrays:
Table:
header:
- Column 1 heading
- Column 2 heading
- Column 3 heading
table:
-
- Column 1 row 1
- Column 2 row 1
- Column 3 row 1
-
- Column 2 row 1
- Will be nothing after this
- Column 3 row 2
-
- ""
- nothing
- Column 3 row 3
-
- Column 4 row 1
- Real
- Column 3 row 4
In your template you can simply use kirbys toStructure()
Example:
<?php $tableX = $page->table()->toStructure(); ?>
<div class="table">
<table>
<thead>
<tr>
<?php foreach($tableX->header() as $headerCell): ?>
<th><?= $headerCell; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach($tableX->table() as $tableRow): ?>
<tr>
<?php foreach($tableRow as $tableCell): ?>
<td><?= $tableCell; ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
To install the plugin, please put it in the site/fields
directory.
The field folder must be named tablex
.
site/fields/
tablex/
tablex.php
...
Link to latest version https://github.com/floriankarsten/kirby-tablex/releases/latest
kirby plugin:install floriankarsten/kirby-tablex
git clone https://github.com/floriankarsten/kirby-tablex/releases.git tablex
You can of course have it as submodule.