Drupal Block Refresh module caveats
stplanken | August 23, 2011 - 11:00 | 38 weeks ago
There is an issue with the Block Refresh module.
After installation and configuration I discovered that the auto refresh was not working. Firefox's Firebug extension showed that requests were made at the proper interval and data was actually returned, but the block's content was simply not being updated.
When in doubt, one of the things you should do is enable a Drupal default theme to exclude any issues with custom code and CSS. It worked in Garland, for example.
I used a simple test block displaying the time stamp in the body and set the interval to, say, 10 seconds:
<?php
print 'Time stamp at last update was: ';
print format_date(time(),'custom','H:i:s');
?>With Firebug I compared the block code from Garland to mine. Garland returned:
<?php
<div class="block block-block" id="block-block-16">
<div class="content">
Time stamp at last update was: 10:47:28
</div>
</div>
?>While my theme returned:
<?php
<div class="defaultblock">
<h2>Auto refresh test</h2>
<div class="blockcontent">
Time stamp at last update was: 10:47:42
</div>
</div>
?>A Drupal forum topic listed the block ID as a possible cause. Indeed, I was not using an ID at all. But after adding the ID, it still didn't work.
Apart from the block ID, Garland uses a class of content and I was using blockcontent. Simply adding the block ID and the content class and it all started working:
<?php
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="defaultblock">
<h2><?php print $block->subject; ?></h2>
<div class="blockcontent content">
<?php print $block->content; ?>
</div>
</div>
?>Which becomes:
<?php
<div class="defaultblock" id="block-block-16">
<h2>Auto refresh test</h2>
<div class="blockcontent content">
Time stamp at last update was: 10:52:45
</div>
</div>
?>In summary, there are several things you need to do:
- Enable the module (of course).
- Set the permissions for the block_refresh.
- Ensure you are using a block ID of:
<div id="block-<?php print $block->module .'-'. $block->delta; ?>"> - Ensure you are using a block content class of:
<div class="content">
These issues are not documented in the README of the module.
Post new comment