bogdancondorachi / kirby-table-field
Kirby CMS的表格字段插件
2.3.2
2024-02-27 17:25 UTC
Requires
README
Kirby Table Field
表格字段插件使得在面板中轻松创建和管理表格成为可能。您可以根据具体需求轻松定制表格,提高数据展示的效率和管理工作。
警告
插件需要Kirby 4。对于Kirby 3,您可以使用v2.1.0版本(尽管不再提供支持)
安装
Composer
composer require bogdancondorachi/kirby-table-field
Git 子模块
git submodule add https://github.com/bogdancondorachi/kirby-table-field.git site/plugins/table-field
手动
下载并将文件夹解压到/site/plugins/table-field
字段使用
将字段添加到您的蓝图
fields: table: label: Table type: table #optional (see field properties)
字段属性
在模板中使用字段
<?php $table = $page->table()->toTable(); if (!empty($table['headers']) && !empty($table['rows'])): ?> <table> <thead> <tr> <?php foreach ($table['headers'] as $header): ?> <th><?= $header ?></th> <?php endforeach ?> </tr> </thead> <tbody> <?php foreach ($table['rows'] as $row): ?> <tr> <?php foreach ($row as $cell): ?> <td><?= $cell ?></td> <?php endforeach ?> </tr> <?php endforeach ?> </tbody> </table> <?php endif ?>
块使用
将块添加到您的蓝图
fields: text: type: blocks fieldsets: - table
蓝图
name: Table icon: table preview: table fields: table: type: table
要覆盖此默认蓝图,请将自定义文件放在/site/blueprints/blocks/table.yml
代码片段
<?php $table = $block->table()->toTable(); if (!empty($table['headers']) && !empty($table['rows'])): ?> <table> <thead> <tr> <?php foreach ($table['headers'] as $header): ?> <th><?= $header ?></th> <?php endforeach ?> </tr> </thead> <tbody> <?php foreach ($table['rows'] as $row): ?> <tr> <?php foreach ($row as $cell): ?> <td><?= $cell ?></td> <?php endforeach ?> </tr> <?php endforeach ?> </tbody> </table> <?php endif ?>
要覆盖此默认代码片段,请将自定义文件放在/site/snippets/blocks/table.php
致谢
- Kirby 团队提供表格布局。
- Rafael Giezendanner提供初始的表格字段插件。
许可证
MIT许可证 版权所有 © 2024 Bogdan Condorachi