Hi!
Is it possible to create a table field in the panel (to manage business hours for exemple)?
Thank you.
Hi!
Is it possible to create a table field in the panel (to manage business hours for exemple)?
Thank you.
The best way to do that would be via a structure field. Then you can create the table in your template.
As an alternative, you can use a standard textarea field and create a table in markdown. You have to enable markdown extra first in your config.php to be able to do that.
But the structure field way of doing that is much more versatile.
Awesome! I’ll try this out. However, I think the markdown approach is not super intuitive for non-technical end users, but thanks for the suggestion!
hi @_jpalbert
yesterday i made a simple
3-col table like this.
blueprint
threeColTableHeadOne:
label: Table head col 1
type: text
width: 1/3
threeColTableHeadTwo:
label: Table head col 2
type: text
width: 1/3
threeColTableHeadThree:
label: Table head col 3
type: text
width: 1/3
threecoltablebody:
label: 3-Col table body
type: structure
style: table
entry: >
{{table-col-1}}<br />
{{table-col-2}}<br />
{{table-col-3}}
fields:
table-col-1:
label: Table body col 1
type: text
table-col-2:
label: Table body col 2
type: text
table-col-3:
label: Table body col 3
type: text
template/snippet
<?php if ($page->threecoltablebody()->isNotEmpty()): ?>
<table>
<?php if ($page->threeColTableHeadOne()->isNotEmpty()): ?>
<thead>
<tr>
<th><?php echo $page->threeColTableHeadOne()->html() ?></th>
<th><?php echo $page->threeColTableHeadTwo()->html() ?></th>
<th><?php echo $page->threeColTableHeadThree()->html() ?></th>
</tr>
</thead>
<?php endif ?>
<tbody>
<?php foreach($page->threecoltablebody()->toStructure() as $tableBodyItem): ?>
<tr>
<td data-label="<?php echo $page->threeColTableHeadOne()->html() ?>"><?php echo $tableBodyItem->table_col_1() ?></td>
<td data-label="<?php echo $page->threeColTableHeadTwo()->html() ?>"><?php echo $tableBodyItem->table_col_2() ?></td>
<td data-label="<?php echo $page->threeColTableHeadThree()->html() ?>"><?php echo $tableBodyItem->table_col_3() ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
panel
frontend
for a table with an unknown count of table columns
i don’t have a simple solution yet…
saludos, funkybrotha
@funkybrotha:
Please help to improve code readability by wrapping code blocks within three backticks at the beginning and the end of a block on a separate line. I have corrected your code above. To see how it works, click on the pencil icon of your post. Thank you.
good morning @texnixe!
aha… ok, i see
the preformatted text function
just makes one…
thanx a lot!
saludos, funkybrotha
maybe you can alsow draw inspration from here and creeate your own field
https://github.com/LCD344/kirby-usersdatatable-plugin1
that plugin is using https://www.datatables.net
Maybe it could help : https://github.com/julien-gargot/kirby-plugin-table/
It’s not perfect, because a lot verbose, but I tried to make it so it will be easier to user to makes table than with the markdown syntaxt, wich is great in Text editor but not really in a textarea fiel…
my problem with the kirby-plugin-table is that you need to have a blank line before and after the ++++ and ////. that made the texte endless long.
but maybe this changed with new syntax (…column…) and (…row…)?
I probably can manage to not take care of line blank before and after… Maybe it already work without, I need to review the code to answer that.
But, anyway, it will be long. It’s more for table with just few cells and long datas than huge table with short values…
just checked again. v 1.1.0 of tableplugin still need blank lines after (…CMD…).