Perforce Chronicle 2012.2/486814
API Documentation
|
Sets up view to add easy cron script. More...
Static Public Member Functions | |
static | load () |
Load the easy cron scripts into the head section of the page. |
Sets up view to add easy cron script.
The Easy Cron module runs the core Cron operation using normal page requests instead of having to set up a crontab. The module inserts a small amount of JavaScript to send Ajax requests on each page when it is enabled (by default, the module is enabled.)
The users should not notice any kind of delay or disruption when viewing the site. However, it does have a performance impact to the server because every page load will send a request to run the cron tasks. The core Cron module will decide if the tasks need to run upon each request.
This module requires that the site gets regular traffic/visitors in order to trigger the cron tasks.
static EasyCron_Module::load | ( | ) | [static] |
Load the easy cron scripts into the head section of the page.
Reimplemented from P4Cms_Module_Integration.
{ // add the script to send a cron run request. $view = Zend_Layout::getMvcInstance()->getView(); $view->headScript()->appendScript( " // we want this to happen last, so we wait until the page // is otherwise loaded, then add 100ms for good measure. dojo.connect(dojo.body(), 'onload', function() { window.setTimeout( function() { dojo.xhrGet({ url: p4cms.url({ module: 'cron', background: true, format: 'json' }) }); }, 100 ); }); " ); }