statikbe/craft-campaign-monitor
最新稳定版本:5.0.1
Composer 安装命令:
composer require statikbe/craft-campaign-monitor
包简介
Add subscribers to a Campaign Monitor list
README 文档
README
Campaign Monitor integration for Craft CMS. Subscribe to a mailing list through a form.
Requirements
This plugin requires Craft CMS 4.0.0 or later.
Installation
To install the plugin, follow these instructions.
- Open your terminal and go to your Craft project:
cd /path/to/project
- Then tell Composer to load the plugin:
composer require statikbe/craft-campaign-monitor
- In the Control Panel, go to Settings → Plugins and click the “Install” button for Campaign Monitor.
Usage
To use:
After installing and enabling the plugin, you'll need to enter your API Key and Client ID from your Campaign Monitor account under Settings > Campaign Monitor.
By default, a contact in Campaign Monitor has the following fields:
- Email (required)
- Name
Basic Subscribe Form
You can implement a subscribe form in your templates using the following code. Note that Resubscribe will be set to true.
<form method="post"> {{ csrfInput() }} {{ actionInput('campaign-monitor/subscribe') }} {{ redirectInput('foo/bar') }} {{ hiddenInput('listId', 'ListID'|hash) }} {{ craft.app.session.getFlash('error') }} <label for="email">E-mail</label> <input type="email" name="email" required /> {# Use firstname + lastname fields, or fullname (optional) #} <label for="firstname">First Name</label> <input type="text" name="firstname" /> <label for="lastname">Last Name</label> <input type="text" name="lastname" /> {# <label for="fullname">Full Name</label> <input type="text" name="fullname" /> #} <button type="submit">Subscribe</button> </form>
Subscribe form with custom fields
Campaign Monitor custom fields can be added in the fields namespace.
For example fields[city], where "city" is the handle of the custom field in Campaign Monitor.
<form method="post"> {{ csrfInput() }} {{ actionInput('campaign-monitor/subscribe') }} {{ redirectInput('foo/bar') }} {{ hiddenInput('listId', 'ListID'|hash) }} {{ craft.app.session.getFlash('error') }} <label for="email">E-mail</label> <input type="email" name="email" required /> <label for="CustomTextField">Custom Text Field</label> <input type="text" name="fields[CustomTextField]" id="CustomTextField" /> <label for="CustomNumberField">Custom Number Field</label> <input type="number" name="fields[CustomNumberField]" id="CustomNumberField" /> <label for="CustomDateField">Custom Date Field</label> <input type="date" name="fields[CustomDateField]" id="CustomDateField" /> <button type="submit">Subscribe</button> </form>
Credits
Heavily inspired by clearbold/craft-campaignmonitor-service and clearbold/craft-campaignmonitor-lists.
统计信息
- 总下载量: 1.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-14