Not to be confused with Ctools contexts.

The Context module, when adding bean blocks using the inline editor, they always return 'This block appears empty when displayed on this page.' and doesn't save to the context.

Not sure if this is a Context issue or a bean issue, but as i've not had issues with any other type of block I can only guess it is something to do with the way Beans return information to the Ajax request from context.

CommentFileSizeAuthor
#1 context-bean_no_work-1933930-1.patch2.12 KBchriscohen

Comments

chriscohen’s picture

Project: Bean (for Drupal 7) » Context
Version: 7.x-1.x-dev » 7.x-3.0-beta6
Status: Active » Needs review
StatusFileSize
new2.12 KB

There is a problem in render_ajax in context_reaction_block.inc in that it assumes that the block is only valid if it contains some #markup.

Beans work differently, yet they can still be rendered using the same method used in that function, it's just that the check to see if it should be rendered is not compatible with the way bean does things.

I'm attaching a patch which makes context "aware" of the way bean does things. I seem to have put more in the patch than I meant to (it's only a one-line fix) - sorry about that. I'm not all that good with patches.

Also it might be that this patch is not suitable because of some other factors of which I'm not aware - I don't have a deep understanding of how context works.

Still, if someone can review this and advise if it is a sensible solution or whether a better one can be proposed, I'd be grateful.

tekante’s picture

Rather than making a bean specific solution, a better approach may be to make the check something along the lines of: if (context_reaction_block_empty($block) ) {

With a new function that does:

/**
* Return true if all display #properties are empty
* no non #keys are found in the content of the block
*/
function context_reaction_block_empty($block) {
$display_properties = array('#markup', '#prefix', '#suffix');
foreach ($block->content as $key => $val) {
if($val && (strpos($key, '#') === FALSE || in_array($display_properties, $key)) {
return TRUE:
}
}
return FALSE;
}

Some research would be needed to determine the exact correct implementation of the empty check but this should allow it to be a little more general.

ianthomas_uk’s picture

Status: Needs review » Closed (duplicate)

This is a specific case of http://drupal.org/node/751062 and would be best fixed with a generic patch there