|
1 |
| -# Buttondown |
| 1 | +# Buttondown for Craft CMS |
| 2 | +This plugin allow you to collect email addresses from your website and send them to your [Buttondown](https://buttondown.com/) newsletter. |
2 | 3 |
|
3 |
| -Buttondown integration |
| 4 | +Note that the plugin is not affiliated with Buttondown in any way - I personally use their service and wanted to create a plugin to make it easier to integrate with Craft CMS. |
4 | 5 |
|
5 |
| -## Requirements |
6 |
| - |
7 |
| -This plugin requires Craft CMS 5.6.0 or later, and PHP 8.2 or later. |
8 | 6 |
|
9 |
| -## Installation |
| 7 | + |
10 | 8 |
|
11 |
| -You can install this plugin from the Plugin Store or with Composer. |
12 | 9 |
|
13 |
| -#### From the Plugin Store |
| 10 | +## Requirements |
| 11 | +This plugin requires Craft CMS 5.6.0 or later. |
14 | 12 |
|
15 |
| -Go to the Plugin Store in your project’s Control Panel and search for “Buttondown”. Then press “Install”. |
16 | 13 |
|
17 |
| -#### With Composer |
| 14 | +## Installation |
| 15 | +To install the plugin, follow these instructions. |
18 | 16 |
|
19 |
| -Open your terminal and run the following commands: |
| 17 | +1. Open your terminal and go to your Craft project: |
20 | 18 |
|
21 | 19 | ```bash
|
22 | 20 | # go to the project directory
|
23 |
| -cd /path/to/my-project.test |
| 21 | +cd /path/to/my-craft-project.dev |
24 | 22 |
|
25 |
| -# tell Composer to load the plugin |
26 |
| -composer require studioespresso/buttondown |
| 23 | +# tell Composer to install the plugin |
| 24 | +composer require studioespresso/craft-buttondown |
27 | 25 |
|
28 | 26 | # tell Craft to install the plugin
|
29 |
| -./craft plugin/install craft-buttondown |
| 27 | +./craft install/plugin buttondown |
30 | 28 | ```
|
| 29 | + |
| 30 | +### Usage |
| 31 | + |
| 32 | +The plugins needs an API key to connect to Buttondown. You can find your API key in your Buttondown account settings. |
| 33 | + |
| 34 | +#### Basic subscriber form |
| 35 | + |
| 36 | +In the simplest form, you only need an input called ``email``, you can post that to the ``buttondown/subscriber`` controller: |
| 37 | +````twig |
| 38 | +<form method="post"> |
| 39 | + {{ csrfInput() }} |
| 40 | + {{ actionInput('buttondown/subscriber') }} |
| 41 | + {{ redirectInput('thanks-for-subscribing') }} |
| 42 | + |
| 43 | + <label for="email-address">{{ "Email address"|t }}</label> |
| 44 | + <input id="email-address" name="email" type="email" autocomplete="email" required> |
| 45 | + |
| 46 | + <button type="submit">{{ "Subscribe"|t }}</button> |
| 47 | +</form> |
| 48 | +```` |
| 49 | + |
| 50 | +#### Fields & tags |
| 51 | + |
| 52 | +Buttondown makes it very easy to add custom fields and tags to subscribers, simply add them as ``fields`` or ``tags`` to the form like the example below: |
| 53 | + |
| 54 | +````twig |
| 55 | +<form method="post"> |
| 56 | + {{ csrfInput() }} |
| 57 | + {{ actionInput('buttondown/subscriber') }} |
| 58 | + {{ redirectInput('thanks-for-subscribing') }} |
| 59 | + |
| 60 | + {# Add custom fields #} |
| 61 | + <label for="firstName" class="sr-only">{{ "First Name"|t }}</label> |
| 62 | + <input id="firstName" name="fields[firstName]" type="text" autocomplete="firstName"> |
| 63 | + |
| 64 | + <label for="email-address">{{ "Email address"|t }}</label> |
| 65 | + <input id="email-address" name="email" type="email" autocomplete="email" required> |
| 66 | + |
| 67 | + {# Add tags, hidden or not #} |
| 68 | + <input type="hidden" name="tags[]" value="{{ siteName }}"> |
| 69 | + <button type="submit">{{ "Subscribe"|t }}</button> |
| 70 | +</form> |
| 71 | +```` |
0 commit comments