Support refreshing of blocs in panels

I am opening this issue to consolidate the issues with the initial release of Block Refresh with Panels support to one thread.

Please post general discussion below. Specific issues relating to Panels support should go in a new issue with this issue marked as the parent.

I look forward to getting this stable very soon!

Current implementation:
- There is now a checkbox on the block's configuration screen allowing for the block to be used in Panels.

Known Issues:
- If a block is used as a regular block AND is used as a block within Panels on the same page then they will both be refreshed together. Not sure that this will actually come up in production implementations, but I did notice it in my initial tests so I wanted to mention it.

Any patches on how to make the UI more user-friendly and/or better approaches to writing the code for this functionality would be MUCH appreciated!

Comments

ah0’s picture

Thank you for your efforts as this is a real need for the block-refresh mod.
Please also note that while working on this, make the functionality work for the HOMEBOX module (http://drupal.org/project/homebox) as well.
HOMEBOX is usually used as much as the panels or used in parallel.
also please ensure that if two panels are added to a page, and each have multiple blocks with block-refreshes, each block refresh can refresh independently from the other ones.

Once again, thank you.
Best,

thomas73’s picture

Hi,

I've got "Call to undefined function block_refresh_submit_panels()" error message when wanted to add my block to a panel.

I've replaced "block_refresh_submit_panels" to "block_refresh_submit" at line 165 in block_refresh.module, and it works now! :)

Regards,
Tamás

mickey86’s picture

Hello,

I have the same problem: view blocks (diaporama cycle) in a panel do not refresh, nor have the "refresh" button on it.

Note, the non-view block in the same panel seem working correctly (also the "refresh" button is displayed). So, it seem related to view blocks in panels.

I have tested the #2 solution (above) with no good results. The checkbox in the block configuration screen do not solve the problem…

Any new idea?

alfiozzz’s picture

Same here, not working inside panels, but working if used for a normal drupal block.

Also looks like this version of block refresh is not working with Internet Explorer 8. Can anyone confirm this ? To me in IE it just does not refresh at all, and if you set manual refresh on, IE does not even show the "Refresh" link.
Firefox is ok.
One little thing: could you please make the Refresh link look more like the theme is use? I know i can customize it but it'd be nice not to see a totally unstilyed link for now. It's a little thing, i said.. :)
Thank you.

p.s. For what I know at the moment this is the only working module that does ajax-refresh content in Drupal 7. Views + Views Hacks module(which provides a auto refresh feature) is not working for Drupal 7. Couldn't you like join forces so that your precious efforts can also be applied on Views+Views Hacks? ...Just my 2 cents :)
Regards

RaulMuroc’s picture

Assigned: bocaj » Unassigned

As I could test, any block (not talking about this particular "block refresh" module but normal blocks) introduced through Views + Panels does not refreshes. Otherwise, when they are blocks just with Views (without Panels) they refresh correctly.

The same for "block refresh" module.

Let's go further, panels doesn't refresh any entity field. For exampe, I created a text area fields under 'profile2' entity, I change repeatedly their value but it is not reflected/refreshed.

Mainly it looks that problem is on panels/ctools refreshing.

RaulMuroc’s picture

Title: Panels Support in Block Refresh 7.x-2.x » Panels Support in Blocks
Project: Block Refresh » Panels
Version: 7.x-2.x-dev » 7.x-3.x-dev

As you can see in the code, it's kind of a matter of design in panels. And thats a pity, because panel pages often serve as overviews of latest content. If used instead of the many blocks aside pages, these panel-pages help to scale traffic down on large sites. Reason enough to provide some way for blocks to work with panels.

Here is the code that might be responsible:

/**
*  implements hook_footer
*  calls the jquery to refresh blocks automatically, but only if the blocks exist on the current page and are enabled
*/
function block_refresh_footer() {
  // don't bother to continue if the user can't refresh content anyway...
  if (!user_access('access block refresh content')) {
    return;
  }
  global $theme_key;
  $blocks = array();
  $regions = system_region_list($theme_key);
  foreach ($regions as $region => $value) {
    $blocks = array_merge($blocks, block_list($region));
  }
...

So just the blocks that are tied to regions are affected. I suppose panels define no page-regions. Someone who knows better about the region-design of panels2 might want to help out here.

merlinofchaos’s picture

Project: Panels » Block Refresh
Version: 7.x-3.x-dev » 7.x-2.x-dev

Yes, Panels does not define regions. The very design makes it impossible.

It seems like a silly coding practice to do it that way, too. But I don't see what Panels can do about this.

AaronELBorg’s picture

EDIT: I'm redacting this post since the behavior I got didn't translate to a site with multiple panes within a panel.

This is extremely quick and dirty so I apologize up front........

But within block_refresh.js you can add some custom code right before line 22 (this is line 22 untouched):
$('#' + element + ' h2').before(refresh_link);

To get the refresh link I added a new line with the panel ID I gave within the panel config ("the-gd-front-page") to line 23. (Maybe this will work out of the box if you don't give the panel an ID??? I don't know.....)
$('#the-gd-front-page h2').before(refresh_link);

And then within the "($'.block-refresh-button').click(function() {...." I added a new block of code to get my stuff to reload as well. Looks like this:

$('#the-gd-front-page .pane-content').load(Drupal.settings.basePath + 'block_refresh/' + settings['block']['block'] + '/' + settings['block']['delta'] + args + query, '', function() {
$('.block-refresh-button').removeClass('block-refresh-button-throbbing');
});

Again, this is so quick and dirty that I'm reluctant to post this. Obviously not that reluctant since you're reading it but, yeah, I gotta make this happen and maybe (just maybe) this will help someone.

AaronELBorg’s picture

Are the settings getting set correctly?

Check out Drupal.settings:

"block_refresh":{"settings":{"block-views-refresher-block":{"element":"block-views-refresher-block","auto":0,"manual":1,"panels":1,"timer":"120","block":{"block":"views","delta":"refresher-block"}}},"args":["front-page","1","8"],"query":""},

In the firebug console I get "undefined" when I do this:

(function ($) { 
$(function(){
alert(Drupal.settings.block_refresh.element);
})
}(jQuery));

Am I doing something weird? In the block config, I have both 'manual' and 'put in a panel' (or whatever it is) checked but other than that, I'm not sure what I could've done to get things in such a wonky state?

egarias’s picture

Maybe it is not the right place, but,

I have ajax error when editing a panel-pane
/panels/ajax/editor/edit-pane/panel_context%3Aterm_view%3Aterm_view_panel_context/5/form

tried to disable some modules but cannot find the way to save my block in the panel

egarias’s picture

I changed as explained in #2 and the seems to work.
But in panels, Modifications on the block are not saved, seems to work with the standard block edit config, but changes are not saved in panels block edit

I have several errors in watchdog:

Notice: Undefined index: module en block_refresh_form_alter() (línea 150 de /var/www/solomoto/sites/all/modules/block_refresh/block_refresh.module).

  • Commit fc325c5 on 7.x-2.x by tripper54:
    Issue #1272556 by tripper54: Panels support
    
tripper54’s picture

Title: Panels Support in Blocks » [Meta] Panels Support in Blocks
Category: Bug report » Feature request
Issue summary: View changes

I have just pushed an update that fixes the error in #2 and #11.

The refresh settings in the panel options form now also works (ie remembers and uses the settings).

We're not quite there yet, but blocks do actually refresh in panels!

I'm going to convert this issue to a meta issue. Please create separate issues for individual bugs and link to this meta issue.

tripper54’s picture

Issue summary: View changes

  • Commit fc325c5 on 7.x-2.x, 8.x-1.x by tripper54:
    Issue #1272556 by tripper54: Panels support
    
tripper54’s picture

Title: [Meta] Panels Support in Blocks » [Meta] Panels Support in Block Refresh
NWOM’s picture

Status: Active » Fixed

Since the changes have been committed, most likely this issue can be closed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.