An open API service indexing awesome lists of open source software.

https://github.com/sjelfull/airtable

Sweet saving and fetching of data with Airtable
https://github.com/sjelfull/airtable

craft-plugin craftcms craftcms-plugin

Last synced: 12 months ago
JSON representation

Sweet saving and fetching of data with Airtable

Awesome Lists containing this project

README

          

# Airtable plugin for Craft CMS

Sweet saving and fetching of data with [Airtable](https://airtable.com/invite/r/znUACjay)

![Icon](resources/icon.png)

## Installation

To install Airtable, follow these steps:

1. Download & unzip the file and place the `airtable` directory into your `craft/plugins` directory
2. Install plugin in the Craft Control Panel under Settings > Plugins
3. The plugin folder should be named `airtable` for Craft to see it.

Airtable works on Craft 2.4.x and Craft 2.5.x.

## Airtable Overview

[Airtable](https://airtable.com/invite/r/znUACjay) is a human-friendly database solution that makes it super easy to manage both simple and complex, relational data.

## Configuring Airtable

```php
'',

// Find this on https://airtable.com/api
'base'
=> '',
// The name of the table. Make sure the capitalization is correct
'table' => '',

// Allowed field keys. This matches the field names in the table
'allowedFields' => [ ],
];
```

## Using Airtable

_Example form_

```twig

{{ getCsrfInput() }}


{% macro errorList(errors) %}
{% if errors %}


    {% for error in errors %}
  • {{ error }}

  • {% endfor %}

{% endif %}
{% endmacro %}

{% from _self import errorList %}

{# Display server error #}
{% if airtable is defined %}
{{ errorList(airtable.getErrors('server')) }}
{% endif %}

Name

{% if airtable is defined %}
{{ errorList(airtable.getErrors('Name')) }}
{% endif %}

E-mail

{% if airtable is defined %}
{{ errorList(airtable.getErrors('E-mail')) }}
{% endif %}

Notes

{%- if airtable is defined %}{{ airtable.Notes }}{% endif -%}

{% if airtable is defined %}
{{ errorList(airtable.getErrors('Notes')) }}
{% endif %}


{% set options = ['First option', 'Second option'] %}
{% for option in options %}


{{ option }}

{% endfor %}

{% if airtable is defined %}
{{ errorList(airtable.getErrors('Single-sele{ct')) }}
{% endif %}


{% set options = ['First option', 'Second option'] %}
{% for option in options %}


{{ option }}

{% endfor %}

{% if airtable is defined %}
{{ errorList(airtable.getErrors('Multi-select')) }}
{% endif %}


Date

{% if airtable is defined %}
{{ errorList(airtable.getErrors('Date')) }}
{% endif %}



Accept terms

{% if airtable is defined %}
{{ errorList(airtable.getErrors('Checkbox')) }}
{% endif %}

```

_Find records in table_
```twig
{% set records = craft.airtable.findRecords() %}
{% if records | length %}



Name
E-mail
Date


{% for record in records %}
{% set fields = record.getFields() %}

{{ fields['Name']|default('') }}
{{ fields['E-mail']|default('') }}
{{ fields['Date']|default('') }}

{% endfor %}

{% endif %}
```

_Find records in table with criteria_

```twig
{% set records = craft.airtable.findRecords({
'Name': 'Thomas'
}) %}
{% if records | length %}



Name
E-mail
Date


{% for record in records %}
{% set fields = record.getFields() %}

{{ fields['Name']|default('') }}
{{ fields['E-mail']|default('') }}
{{ fields['Date']|default('') }}

{% endfor %}

{% endif %}
```

## Airtable Roadmap

Some things to do, and ideas for potential features:

* Support multiple tables
* Support attachments
* Add logging

Brought to you by [Superbig](https://superbig.co)