When a block is added to panel pages, the block_refresh code inserted into the footer does not work because panels use different CSS to render the blocks.

Comments

agogo’s picture

Block refresh doesnt work in panels AT ALL.

Ive reviewed the issue queue and have seen that all other issues that handle this problem is marked as wont fix. But I dont really understand why.

Since the release of Drupal 7, Panels has become such a standard and widely used module that support from this module for blocks used in panels is vital for the module to survive.

I must say that the functionality this module offers is superb and it would be a shame if it didnt get updated just because people that wants Panels support doesnt post on the same issue twice a week.

Ill set of time to try to come up with a solution for the problem. Just dont set the status as wont fix again since Panels support Is wanted for this module.

bocaj’s picture

We will definitely look into fixing this issue. I think that Block Refresh should be compatible with Panels too!

If anyone has a patch to submit that would be greatly appreciated!

jhm’s picture

I actually started experimenting with the following code, but had to give up when block_refresh went into a tail-spin and almost took down my server (some run-away condition) ... maybe someone else can pick this up. The problem with block_refresh is that it uses hooks that normally do not fire on panel pages

function MYMODULE_preprocess_block($content) {
	global $preprocess_block_refresh_js;
	if(module_exists('block_refresh')) {
		static $settings;
		if(!isset($settings)) {
			$settings = variable_get('block_refresh_settings', array());
		}
		$bid = sprintf('block-%s-%d', $content['block']->module, $content['block']->delta);
		if(isset($settings[$bid]) && ($block = $settings[$bid])) {
			$js = '';
			// I believe (though have not thoroughly tested) that this is an unnecessary test
			if ($block['enabled']) {
				// this is the block div css id and content class
				$id = "pane-{$block['block']['block']}-{$block['block']['delta']}";
				$div = "#$id .pane-content";

				// we store seconds, but js expects milliseconds
				$timer = $block['timer'] * 1000;

				$base = base_path();
				$js .= "  \$('.$id').attr('id', '$id');\n";
				$js .= "  _block_refresh_data['#$div'] = new block_refresh_data({$timer}, '{$base}block_refresh/{$block['block']['block']}/{$block['block']['delta']}');\n";
				$js .= "  block_refresh_timer('#$div');\n";
			}
			// If the block is configured to be user-refreshed
			if ($block['manual']) {
				// this is the block div css id and content class
				$div = "pane-{$block['block']['block']}-{$block['block']['delta']}";

				$base = base_path();
				$url = "{$base}block_refresh/{$block['block']['block']}/{$block['block']['delta']}";
				$content_url = "#$div .pane-content";
				$js .= "  block_refresh_add_button('$div', '$url', '$content_url');\n";
			}
			if($js) $preprocess_block_refresh_js .= $js;
		}
	}
}
function MYMODULE_footer() {
	global $preprocess_block_refresh_js;

	if (module_exists('block_refresh') && !empty($preprocess_block_refresh_js)) {
		drupal_add_js('<!--'.__FUNCTION__.'-->'."\n\$(document).ready(function() {\n$preprocess_block_refresh_js\n})", 'inline', 'footer');
		$preprocess_block_refresh_js = null;
	}
}
ah0’s picture

Hey guys,
Any one came up with a soluton for the compatibility with panels?
any help / comments much appreciated,
thanks

bocaj’s picture

Status: Active » Closed (duplicate)

I have created an issue to consolidate all issues regarding Panels implementation in the next release of Block Refresh here: #1272556: [Meta] Panels Support in Block Refresh.

sierea’s picture

Issue summary: View changes

I was able to get it to refresh in panels or mini panels or whatever using php
this uses block load so it accesses the 'block' settings ie refresh


$block = block_load('views', 'intownshow-block');
print drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));

'views' would be the name of your module
'intownshow-block' is the name of the block.

Find these in the configure url on the blocks page