dtgr3392 2017-03-23 09:21
浏览 71

10月CMS实时更新数据

Is there some plugin for October CMS that allows to update data in different fields on site in real time? May be there is some october ajax api or class wherein it is implemented depending on DB change event? For example I need to update fields in my plugin managment panel if someone else at this time made a change. Unfortunately, link to the Real time chat plugin does not work. But I don't need chat solution in my case. I would not want to remodel it. Just need to mark fileds that should be updated if there were some changes in DB relative to them. It would be great if it was implemented in a simple way. Otherwise I have to implement some long-polling/websocket api/class.

  • 写回答

1条回答 默认 最新

  • dsa4d4789789 2017-03-26 07:27
    关注

    To solve this I'd recommend to use Pusher They got good free plan. The steps to implement would be:

    1. Creating pusher instance

      window.pusher = new Pusher('APIKEY', {
          cluster: 'eu',//some problems reported about eu cluster sometimes
          authEndpoint: '/pusher/auth'
      });
      
    2. Creating private channel wich will notify you about changes.

      var channel = window.pusher.subscribe('private-notify');
      
    3. Subscribing to that channel. Here will go update function to change any your interface.

      channel.bind('client-messagesent', function(data) {
         //change your interface
      });
      
    4. Pushing info from backend about changes by other users to the same channel triggering the event to call function from (3).

      $pusher->trigger('private-notify', 'client-messagesent', $data);
      

    To start you will need include one CDN pusher script. Plenty tutorials here https://pusher.com/tutorials

    There is also Pusher plugin for OctoberCMS but I ended setting pusher from scratch because that plusign adds a lot of redundant things.

    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统