dtrvzd1171 2014-06-17 15:11
浏览 8
已采纳

PyroCMS在流保存后执行代码

So I've got a PyroCMS project that I'm working on that is a backend for a mobile app. What I'm trying to do is send push notifications when a certain stream gets a new entry.

From what I've read here, it looks like there is no way to tell when the form data is actually saved with cp->entry_form()

Anyone have any insight?

  • 写回答

1条回答 默认 最新

  • doudian7996 2014-07-01 09:57
    关注

    Events to the rescue!

    Check out the docs on events.

    Basically you'll have to create an events.php in your module (and maybe even create a small module with no functionality besides this) and register for the streams_post_insert_entry and streams_post_update_entry events.

    Example events.php:

    <?php defined('BASEPATH') or exit('No direct script access allowed');
    
    class Events_Yourmodule
    {
        protected $ci;
    
        public function __construct()
        {
            $this->ci =& get_instance();
    
            Events::register('streams_post_insert_entry', array($this, 'delete_cache'));
            Events::register('streams_post_update_entry', array($this, 'delete_cache'));     
        }
    
        public function delete_cache( $event )
        {
            // check if the event is for the stream we're interested in
            if($event['stream']->stream_slug != 'the-stream-im-interested-in')
              return;
    
            // now, do stuff... like delete cache
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 使用Java milo连接Kepserver服务端报错?
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了
  • ¥15 微信小程序商城如何实现多商户收款 平台分润抽成
  • ¥15 HC32L176调试了一个通过TIMER5+DMA驱动WS2812B
  • ¥15 cocos的js代码调用wx.createUseInfoButton问题!
  • ¥15 关于自相关函数法和周期图法实现对随机信号的功率谱估计的matlab程序运行的问题,请各位专家解答!
  • ¥15 Python程序,深度学习,有偿私