bogdancondorachi/kirby-table-field

Kirby CMS的表格字段插件

安装次数: 3,144

依赖项: 0

建议者: 0

安全: 0

星标: 35

关注者: 2

分支: 2

公开问题: 9

语言:Vue

类型:Kirby 插件

2.3.2 2024-02-27 17:25 UTC

This package is auto-updated.

Last update: 2024-09-22 11:28:31 UTC


README

Kirby Table Field

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

致谢

许可证

MIT许可证 版权所有 © 2024 Bogdan Condorachi