goldinteractive/craft-publisher 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

goldinteractive/craft-publisher

Composer 安装命令:

composer require goldinteractive/craft-publisher

包简介

Publisher X enables you to publish saved Drafts on a future date without the need to handle the cache expiration logic. The cronjob handles the publication and the cache invalidation.

README 文档

README

Publisher X enables you to publish saved Drafts on a future date. The cron job handles the publication, and cache invalidation is managed through Craft CMS's native element save events.

It also handles entries that are set to expire or go live in the future, and will trigger cache invalidation through Craft's standard element lifecycle events.

Screenshot

Requirements

  • Craft CMS 5.0+
  • PHP 8.2+

Installation

composer require nst/craft-publisher

Then install the plugin in the Craft control panel under Settings → Plugins.

Permissions

To publish a draft, the user needs the Save entries permission on the entry's section.

Setup

Create a cron job that runs every minute. You can invoke Publisher X via CLI or HTTP:

CLI (recommended):

* * * * * [PATH_TO_CRAFT]/craft publisher-x/publish

Web:

* * * * * /usr/bin/curl --silent --compressed {siteUrl}/actions/publisher-x/api/publish

Usage with cache plugins

If you use a full-page cache plugin such as Blitz, make sure you also run the queue and refresh expired caches:

* * * * * [PATH_TO_CRAFT]/craft blitz/cache/refresh-expired
* * * * * [PATH_TO_CRAFT]/craft queue/run

Events

EVENT_AFTER_PUBLISH_ENTRY

Fired by the Entries service after each successful scheduled publication. Use it to trigger server-side cache purges or any other side-effect tied to publication.

Event::on(
    Entries::class,
    Entries::EVENT_AFTER_PUBLISH_ENTRY,
    function (EntryPublishedEvent $event) {
        $entry = $event->entry;        // canonical entry that was published
        $draft = $event->draft;        // draft that was applied, or null for non-draft schedules
        $schedule = $event->entryPublish; // the EntryPublish schedule record

        // trigger your cache purge here
    }
);

The event is only fired when publication succeeds. If the scheduled entry or draft cannot be found (e.g. the entry was deleted), the orphaned record is cleaned up and the event is not fired.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固