Silverstripe 3:如何在设定的日期取消发布页面?

Silverstripe 3: How can you unpublish pages on a set date?

我想将页面设置为在 silverstripe 3 上的设定日期自动取消发布。

我在网上看到了多种解决方案,主要是使用某些模块,但是 none 其中一些与 silverstripe 3 兼容,很多模块说它们现在被放弃了,如果不是我明白了作曲家出现以下错误

[InvalidArgumentException]                                                                                                        
  Could not find a matching version of package xxxxxxxx. Check the package spelling, your version constr  
  aint and that the package is available in a stability which matches your minimum-stability (dev).

有人有 silverstripe 3 的完整解决方案吗?

您正在寻找的很可能是用于计划作业的禁运模块 (https://github.com/silverstripe-terraformers/silverstripe-embargo-expiry). In combination with the queuedjobs modules (https://github.com/symbiote/silverstripe-queuedjobs) 允许安排数据对象(例如页面)的发布和取消发布。

您可以安装模块:

composer require silverstripe-terraformers/embargo-expiry symbiote/silverstripe-queuedjobs

并将配置添加到 SiteTree:

SiteTree:
  extensions:
    - SilverStripe\Versioned\Versioned
    - Terraformers\EmbargoExpiry\Extension\EmbargoExpiryExtension

运行 dev/build 之后,您应该可以在 CMS 中设置日期。

在您的生产环境中,您需要确保配置一个与此类似的 cronjob:

*/1 * * * * php /path/to/silverstripe-project/framework/cli-script.php dev/tasks/ProcessJobQueueTask

对于本地测试,您应该能够 运行:

php ./framework/cli-script.php dev/tasks/ProcessJobQueueTask

通过上述步骤,您应该能够在 SilverStripe 中设置页面过期 3.x。

干杯, 彼得