Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📈 Table field/block plugin for Kirby CMS

License

NotificationsYou must be signed in to change notification settings

bogdancondorachi/kirby-table-field

Repository files navigation

Kirby Table Field

VersionDependencyDependencyDownloads

Note

This flexible yet powerful panel field is designed to effortlessly manage and display large datasets. It enables users to dynamically add, edit, and organize data in rows and columns, offering intuitive controls for adding, removing, duplicating, and rearranging entries. Ideal for handling complex data structures while ensuring a clean and user-friendly interface.

Installation

Composer

composer require bogdancondorachi/kirby-table-field

Git Submodule

git submodule add https://github.com/bogdancondorachi/kirby-table-field.git site/plugins/table-field

Manual

Download and extract the folder to/site/plugins/table-field

Field Usage

Add the field to your blueprint:

fields:table:label:Tabletype:table# optional (see field properties)

Field Properties:

NameTypeDefaultDescription
alignstring-Set the text alignment of the table
disabledbool-Iftrue, the field is no longer editable and will not be saved
duplicatebooltrueToggles duplicating columns and rows in the table
emptystring-The placeholder text if no rows exists
helpstring-Optional help text below the field
indexint,bool1Specifies the starting index. If set tofalse, it removes the index column; in this case,sortable would be disabled as well
labelstring-Set the label above the field
marksbool,arraytrueSet the allowed HTML formats. Activate/deactivate them all by passingtrue/false
maxColumnsint8Set the maximum allowed columns in the table
minColumnsint2Set the minimum required columns in the table
sortablebooltrueToggles drag & drop sorting
translatebooltrueIffalse, the field will be disabled in non-default languages and cannot be translated. This is only relevant in multi-language setups.

Use the field in your template:

<?php$table =$page->table()->toTable();if (!empty($table['headers']) && !empty($table['rows'])):?>  <table>    <thead>      <tr><?phpforeach ($table['headers']as$header):?>          <th><?=$header?></th><?phpendforeach?>      </tr>    </thead>    <tbody><?phpforeach ($table['rows']as$row):?>        <tr><?phpforeach ($rowas$cell):?>            <td><?=$cell?></td><?phpendforeach?>        </tr><?phpendforeach?>    </tbody>  </table><?phpendif?>

Blocks Usage

Add the block to your blueprint:

fields:text:type:blocksfieldsets:      -table

Overwrite default blueprint:

name:Tableicon:tablepreview:dataTablefields:table:type:tablecaption:type:writericon:textinline:true

To overwrite the default blueprint, place your custom file in/site/blueprints/blocks/table.yml

Snippet:

<?php$table =$block->table()->toTable();if (!empty($table['headers']) && !empty($table['rows'])):?>  <table>    <thead>      <tr><?phpforeach ($table['headers']as$header):?>          <th><?=$header?></th><?phpendforeach?>      </tr>    </thead>    <tbody><?phpforeach ($table['rows']as$row):?>        <tr><?phpforeach ($rowas$cell):?>            <td><?=$cell?></td><?phpendforeach?>        </tr><?phpendforeach?>    </tbody>  </table><?phpendif?>

To overwrite this default snippet, place your custom file in/site/snippets/blocks/table.php

Buy me a coffee ☕

Note

This plugin is provided free of charge & published under the permissive MIT License. If you're using it for a commercial project or just want to help keep it alive, please considerdonating. Your support fuels future development!

License

MIT License Copyright © 2024Bogdan Condorachi

Sponsor this project

 

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp