GithubHelp home page GithubHelp logo

mrnebbi / tablemaker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from verbb/tablemaker

0.0 0.0 0.0 242 KB

A user-definable table field type for Craft CMS

License: MIT License

JavaScript 28.34% PHP 64.93% HTML 5.82% SCSS 0.90%

tablemaker's Introduction

Table Maker Plugin for Craft CMS

Let your users define their own table columns in your Craft control panel.

Table Maker

Installation

You can install Table Maker via the plugin store, or through Composer.

Craft Plugin Store

To install Table Maker, navigate to the Plugin Store section of your Craft control panel, search for Table Maker, and click the Try button.

Composer

You can also add the package to your project using Composer and the command line.

  1. Open your terminal and go to your Craft project:
cd /path/to/project
  1. Then tell Composer to require the plugin, and Craft to install it:
composer require verbb/tablemaker && php craft plugin/install tablemaker

Usage

There are two ways you can go about templating a table: use the built-in html output or access the column and row data directly to code your own.

Automatic table output

This will simply output a valid html table:

{{ entry.myTableField.table }}

Code your own

Should you want more control over the output you can just access the column and row data directly instead using {{ entry.myTableField.columns }} and {{ entry.myTableField.rows }}.

Here is an example of how you might do just that:

<table>
    <thead>
        <tr>
            {% for col in entry.myTableField.columns %}
                <th align="{{ col.align }}" width="{{ col.width }}">{{ col.heading }}</th>
            {% endfor %}
        </tr>
    </thead>

    <tbody>
        {% for row in entry.myTableField.rows %}
            <tr>
                {% for cell in row %}
                    <td align="{{ entry.myTableField.columns[loop.index0].align }}">{{ cell }}</td>
                {% endfor %}
            </tr>
        {% endfor %}
    </tbody>
</table>

Note that when looping rows you can use the current loop index to find the appropriate alignment value for that column.

Credits

Originally created by the team at Supercool Ltd.

Show your Support

Table Maker is licensed under the MIT license, meaning it will always be free and open source โ€“ we love free stuff! If you'd like to show your support to the plugin regardless, Sponsor development.

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.