You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-6Lines changed: 52 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,7 @@
4
4
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.
5
5
6
6
> [!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)
9
8
10
9
## Installation
11
10
@@ -22,9 +21,9 @@ git submodule add https://github.com/bogdancondorachi/kirby-table-field.git site
22
21
23
22
### Manual
24
23
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`
26
25
27
-
## Usage
26
+
## Field Usage
28
27
29
28
### Add the field to your blueprint:
30
29
```yaml
@@ -42,8 +41,8 @@ fields:
42
41
| duplicate |`bool`|`true`| Toggles duplicating columns and rows in the table |
43
42
| empty |`string`|`-`| The placeholder text if no rows exists |
44
43
| 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|
47
46
| maxColumns |`int`|`5`| Sets the maximum allowed columns in the table |
48
47
| minColumns |`int`|`2`| Sets the minimum required columns in the table |
49
48
| sortable |`bool`|`true`| Toggles drag & drop sorting |
@@ -74,6 +73,53 @@ fields:
74
73
<?php endif ?>
75
74
```
76
75
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
+
77
123
## Credits
78
124
79
125
- [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