定制 storychief/craft-cms-v3-storychief 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

storychief/craft-cms-v3-storychief

最新稳定版本:5.0.0

Composer 安装命令:

composer require storychief/craft-cms-v3-storychief

包简介

Craft CMS plugin to use with Storychief

README 文档

README

Craft CMS plugin to use with StoryChief.

Requirements

Craft CMS version Branch
Craft CMS 5 craft-cms-5
Craft CMS 4 craft-cms-4
Craft CMS 3 craft-cms-3

If you are still using Craft CMS 2.x, you can find the right plugin here.

Installation

You can install this plugin from the Plugin Store or with Composer.

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for “Storychief”. Then click on the “Install” button in its modal window.

With Composer

Open your terminal and run the following commands:

# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require storychief/craft-cms-v3-storychief

# tell Craft to install the plugin
./craft install/plugin storychief-v3

Activate

To activate the plugin you first need to set up a new Craft CMS channel on your StoryChief admin panel. As soon as you create one, it will give you an encryption key .

In your CRAFT CMS, go to your Settings/Plugins and activate your StoryChief plugin. Go to its Settings and fill the encryption key and website URL.

Save it.

Finally, back to your StoryChief CRAFT CMS channel configuration, fill up your CRAFT CMS site URL and save

:)

Events

Note: this is mostly for developers that know basic PHP and Composer Packages.

beforeEntryPublish and beforeEntryUpdate event

This allows developers to execute custom functionality before saving a new or updating an entry, to modify data of a new entry.

use storychief\storychiefv3\events\EntryPublishEvent;

$this->on('beforeEntryPublish', function (EntryPublishEvent $event) {
    $payload = $event->payload;
    $settings = $event->settings;
    $entry = $event->entry;

    // Example 1:
    $entry->sectionId = 2; // BLog
    $entry->typeId = 2;

    // Example 2:
    if ($payload['data']['custom_fields']) {
        foreach ($payload['data']['custom_fields'] as $customField) {
            if ($customField['key'] === 'custom_field_name') {
                $entry->sectionId = $customField['value'];
                $entry->typeId = 2;
            }
        }
    }
});

use storychief\storychiefv3\events\EntryUpdateEvent;

$this->on('beforeEntryUpdate', function (EntryUpdateEvent $event) {
    // ...
});

afterEntryPublish event

This allows developers to execute custom functionality after a new entry, pushed by Storychief, is saved in Craft.

afterEntryUpdate event

This allows developers to execute custom functionality after an update to an entry, pushed by Storychief, is saved in Craft.

Both events send out a EntrySaveEvent with the saved Entry object as its property.

Brought to you by StoryChief

统计信息

  • 总下载量: 1.45k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-21