Thanks for the module.
It would be very useful if the refresh could be evaluated in a condition or even triggered by an action by Rules module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tripper54’s picture

That is a good idea. I'll add it to the roadmap, patches welcome in the mean time!

paean99’s picture

Unfortunately i do not really have much time to pursue this idea at this time. And i do not consider myself a developer or have much knowledge on Rules programming. But I will share here some quick thoughts that i had at the time and a quick example patch for the Rules event integration.

The event part is the easiest and do not need much thinking, although it only pass the block ID at this time. Patch included.

About the condition part, i do not see an use at this moment for it. Maybe passing the block refresh settings and use them later on some sort of check. This could enable Rules to change the Block settings (change refresh interval, disabling refresh, ...).

On the other hand, the action integration might be the most useful part of the idea, but it is also the one that deserves a little more work.
To be able to refresh certain pages at will from the server would probably need a complete rewrite of the module and the use of node.js and socket.io or something similar. I think that it is out of the scope of this issue. Better write a new module. I may be wrong...

A simple workaround could be to create a new Checkbox 'Rules integration' on the block refresh settings. On page load the javascript on the client side would check that setting and, if true, enable an interval to check for an internal flag 'execute refresh' on the block settings. If that flag is set then the javascript would refresh the block. On the block_refresh_block_content function, the flag could be reset at the end.

I used the code from Itangalo 's Rules examples module (https://www.drupal.org/project/rules_example) and its screencast 'Coding for Rules 2' (http://nodeone.se/en/coding-for-rules-2) to do the event patch.

Hope this helps.

Edit: some orthographic corrections and added link to screencast.