Thank you for the tip.
One more question. If I use cron to generate my content at a regular intervals should I just wait for the page to refresh and then rely on get_content() or as I think I understand the documentation I can essentially recreate each instance of the block and set the content from the cron handler directly? Do you have any experience with either approach?
http://docs.moodle.org/dev/Blocks
NOTE: The block cron is designed to call the cron script for that block type only. That is, cron does not care about individual instances of blocks. Inside your cron function $this is defined, but it has almost nothing in it (only title and content fields are populated). If you need to execute cron for individual instances it is your own responsibility to iterate over them in the block's cron function. Example:
public function cron() {
global $DB; // Global database object
// Get the instances of the block
$instances = $DB->get_records( 'block_instance', array('blockid'=>'simplehtml') );
// Iterate over the instances
foreach ($instances as $instance) {
// Recreate block object
$block = block_instance('simplehtml', $instance);
// $block is now the equivalent of $this in 'normal' block
// usage, e.g.
$someconfigitem = $block->config->item2;
}
}
TIP: This also means that creating a block is a possible way to create code that can respond to cron with a reasonably low overhead. No actual instances of the block are required.