GithubHelp home page GithubHelp logo

floriankarsten / kirby-tablex Goto Github PK

View Code? Open in Web Editor NEW
65.0 8.0 6.0 274 KB

KIRBY 2 ONLY. No plans for K3 version yet. Table field for Kirby CMS.

CSS 1.18% JavaScript 97.41% PHP 1.40%
kirby kirby-field kirby-cms

kirby-tablex's Introduction

Kirby 2 only. There are no plans for Kirby 3 version yet.

Kirby tablex

Kirby tablex - simple table field for Kirby CMS. Advice, features and sugestions welcome.

Kirby tablex GIF

Usage

As any field in blueprint:

  table:
    label: table
    type: tablex
    options: 
      maxColumns: 10
      minColumns: 3
      header: false

Options are not required. Defaults are:

        maxColumns: 10
        minColumns: 1
        header: false

Content is then structured as regular yaml arrays:

Table: 

header:
  - Column 1 heading
  - Column 2 heading
  - Column 3 heading
table:
  - 
    - Column 1 row 1
    - Column 2 row 1
    - Column 3 row 1
  - 
    - Column 2 row 1
    - Will be nothing after this
    - Column 3 row 2
  - 
    - ""
    - nothing
    - Column 3 row 3
  - 
    - Column 4 row 1
    - Real
    - Column 3 row 4

In your template you can simply use kirbys toStructure()

Example:

<?php $tableX = $page->table()->toStructure(); ?>
<div class="table">
	<table>
		<thead>
			<tr>
				<?php foreach($tableX->header() as $headerCell): ?>
					<th><?= $headerCell; ?></th>
				<?php endforeach; ?>
			</tr>
		</thead>
		<tbody>
			<?php foreach($tableX->table() as $tableRow): ?>
				<tr>
					<?php foreach($tableRow as $tableCell): ?>
						<td><?= $tableCell; ?></td>
					<?php endforeach; ?>
				</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
</div>

Installation

To install the plugin, please put it in the site/fields directory.
The field folder must be named tablex.

site/fields/
    tablex/
        tablex.php
        ...

Download

Link to latest version https://github.com/floriankarsten/kirby-tablex/releases/latest

With Kirby CLI

kirby plugin:install floriankarsten/kirby-tablex

With Git

git clone https://github.com/floriankarsten/kirby-tablex/releases.git tablex You can of course have it as submodule.

What we are not sure about - ideas, opinions welcome :)

  • Naming, we chose stupid name kirby-tablex because we were worried about namespace pollution.
  • How to properly pass data from kirby to JS. We are rendering ui only with JS. HTML doesn't come rendered from server. All data is passed to data-attribute of root element and taken from there. We are not sure how to make this safe properly. If you start to put ' and stuff like that into Tablex things will break.

kirby-tablex's People

Contributors

iskrisis avatar krisak avatar mightybart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.