Skip to content

Commit c6a71b0

Browse files
chore: update readme
1 parent 25654f9 commit c6a71b0

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

README.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
The table field makes possible to effortlessly create and manage tables within the panel. You can easily tailor tables to their specific needs, enhancing the efficiency and management of data presentation.
55

66
> [!WARNING]
7-
> Starting from version [v2.2.0](https://github.com/bogdancondorachi/kirby-table-field/releases/tag/v2.2.0), this plugin is compatible only with Kirby 4.<br />
8-
> If you are still using Kirby 3, it's recommended to stick with [v2.1.0](https://github.com/bogdancondorachi/kirby-table-field/releases/tag/v2.1.0) for compatibility.
7+
> **The plugin requires Kirby 4**. For Kirby 3, you can use [v2.1.0](https://github.com/bogdancondorachi/kirby-table-field/releases/tag/v2.1.0) (although without further support)
98
109
## Installation
1110

@@ -22,9 +21,9 @@ git submodule add https://github.com/bogdancondorachi/kirby-table-field.git site
2221

2322
### Manual
2423

25-
[Download](https://api.github.com/repos/bogdancondorachi/kirby-table-field/zipball) and extract the folder to `/site/plugins/kirby-table-field`
24+
[Download](https://api.github.com/repos/bogdancondorachi/kirby-table-field/zipball) and extract the folder to `/site/plugins/table-field`
2625

27-
## Usage
26+
## Field Usage
2827

2928
### Add the field to your blueprint:
3029
```yaml
@@ -42,8 +41,8 @@ fields:
4241
| duplicate | `bool` | `true` | Toggles duplicating columns and rows in the table |
4342
| empty | `string` | `-` | The placeholder text if no rows exists |
4443
| help | `string` | `-` | Optional help text below the field |
45-
| index | `int`, `bool` | `1` | Specifies the starting index. If set to `false`, it removes the index column; in this case, `sortable` also needs to be set to `false` |
46-
| label | `string` | `-` | The field label above the field |
44+
| index | `int`, `bool` | `1` | Specifies the starting index. If set to `false`, it removes the index column; in this case, `sortable` would be disabled as well |
45+
| label | `string` | `-` | Sets the label above the field |
4746
| maxColumns | `int` | `5` | Sets the maximum allowed columns in the table |
4847
| minColumns | `int` | `2` | Sets the minimum required columns in the table |
4948
| sortable | `bool` | `true` | Toggles drag & drop sorting |
@@ -74,6 +73,53 @@ fields:
7473
<?php endif ?>
7574
```
7675

76+
## Blocks Usage
77+
78+
### Add the block to your blueprint:
79+
```yaml
80+
fields:
81+
text:
82+
type: blocks
83+
fieldsets:
84+
- table
85+
```
86+
### Blueprint:
87+
```yaml
88+
name: Table
89+
icon: table
90+
preview: table
91+
fields:
92+
table:
93+
type: table
94+
```
95+
To overwrite this default blueprint, place your custom file in `/site/blueprints/blocks/table.yml`
96+
97+
### Snippet:
98+
```php
99+
<?php $table = $block->table()->toTable(); ?>
100+
<?php if($table != null): ?>
101+
<table>
102+
<thead>
103+
<tr>
104+
<?php foreach ($table['headers'] as $header): ?>
105+
<th><?= $header ?></th>
106+
<?php endforeach ?>
107+
</tr>
108+
</thead>
109+
<tbody>
110+
<?php foreach ($table['rows'] as $row): ?>
111+
<tr>
112+
<?php foreach ($row as $cell): ?>
113+
<td><?= $cell ?></td>
114+
<?php endforeach ?>
115+
</tr>
116+
<?php endforeach ?>
117+
</tbody>
118+
</table>
119+
<?php endif ?>
120+
```
121+
To overwrite this default snippet, place your custom file in `/site/snippets/blocks/table.php`
122+
77123
## Credits
78124

79125
- [Kirby Team](https://getkirby.com) for the [table](https://github.com/getkirby/kirby/blob/main/panel/src/components/Layout/Table.vue) layout.

0 commit comments

Comments
 (0)