diff --git a/CHANGELOG.md b/CHANGELOG.md index fbe44a7..a1be52b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Read-only Field Changelog +## 1.0.1 - 2019-09-14 +### Added +- Support for Feed-Me plugin + ## 1.0.0 - 2019-04-06 ### Added - Initial release diff --git a/composer.json b/composer.json index 50e84ec..2436610 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "codemonauts/craft-readonly-field", "description": "Craft CMS plugin to add a simple, read-only plaintext field.", - "version": "1.0.0", + "version": "1.0.1", "type": "craft-plugin", "keywords": [ "craft", diff --git a/src/Readonly.php b/src/Readonly.php index 2802fdb..c3b1619 100644 --- a/src/Readonly.php +++ b/src/Readonly.php @@ -2,11 +2,14 @@ namespace codemonauts\readonly; -use \craft\base\Plugin; +use craft\base\Plugin; use craft\events\RegisterComponentTypesEvent; use craft\services\Fields; use yii\base\Event; use codemonauts\readonly\fields\Readonly as ReadonlyField; +use codemonauts\readonly\feedme\Readonly as ReadonlyFeedme; +use craft\feedme\events\RegisterFeedMeFieldsEvent; +use craft\feedme\services\Fields as FeedMeFields; class Readonly extends Plugin { @@ -17,5 +20,13 @@ public function init() Event::on(Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, function(RegisterComponentTypesEvent $event) { $event->types[] = ReadonlyField::class; }); + + // Register field for feed-me plugin if installed + if (\Craft::$app->plugins->isPluginEnabled('feed-me')) { + Event::on(FeedMeFields::class, FeedMeFields::EVENT_REGISTER_FEED_ME_FIELDS, function(RegisterFeedMeFieldsEvent $e) { + $e->fields[] = ReadonlyFeedme::class; + } + ); + } } } diff --git a/src/feedme/Readonly.php b/src/feedme/Readonly.php new file mode 100644 index 0000000..348389d --- /dev/null +++ b/src/feedme/Readonly.php @@ -0,0 +1,22 @@ +fetchValue(); + } +} diff --git a/src/templates/feedme.twig b/src/templates/feedme.twig new file mode 100644 index 0000000..dfb2b50 --- /dev/null +++ b/src/templates/feedme.twig @@ -0,0 +1,18 @@ +{# ------------------------ #} +{# Available Variables #} +{# ------------------------ #} +{# Attributes: #} +{# type, name, handle, instructions, attribute, default, feed, feedData #} +{# ------------------------ #} +{# Fields: #} +{# name, handle, instructions, feed, feedData, field, fieldClass #} +{# ------------------------ #} + +{% import 'feed-me/_macros' as feedMeMacro %} +{% import '_includes/forms' as forms %} + +{% set default = default ?? { + type: 'text', +} %} + +{% extends 'feed-me/_includes/fields/_base' %}