Block title disappears for custom static blocks created through the block UI, when they are set to display in a context. Assigning the same block to some region through the block UI gets the title to display as it should. Blocks provided by views & other contrib modules however display their titles correctly in contexts.

Using core 7.0-rc1 and Context 7.x-3.0-alpha2.

Comments

askibinski’s picture

StatusFileSize
new1.09 KB

The way I see it the title isn't anywhere loaded through context module as it is in a seperate table {blocks}. The body is loaded from {blocks_custom}.

In attached patch, I used the new drupal 7 block_load function to load the entire block object in case it is a custom block. It solves the problem but I think it needs work.

BarisW’s picture

Hey Albert,

thanks. The patch fixes the bug. It needed a little tweak thought.
Instead of

  $block->cache = isset($info[$block->bid]->cache) ? $info[$block->bid]->cache : DRUPAL_NO_CACHE;
  $block->bid = "{$block->module}-{$block->delta}";
  $block->context = $context->name;

it should be

  $block->bid = "{$block->module}-{$block->delta}";
  $block->cache = isset($info[$block->bid]->cache) ? $info[$block->bid]->cache : DRUPAL_NO_CACHE;
  $block->context = $context->name;

As $block->cache checks if $block->bid isset, which is set the next line.
After swapping these two lines, the titles are back! :)

Thanks!

aidanlis’s picture

Subscribe

pivica’s picture

Version: 7.x-3.0-alpha2 » 7.x-3.x-dev
Component: Miscellaneous » Code
StatusFileSize
new2.29 KB

I have spend half a day trying to find some better solution for this problem, but no luck. Seems to me that approach from #1 is currently the only possible way to get titles for custom blocks.

Here is a new patch against latest 7.x-3.x-dev. Logic is the same like in #1 but I have added new static function block_load() into context_reaction_block class which I am using instead of Drupal block_load because I think that we should query block with delta and with theme_key.

I don't like this approach at all, but at least custom block titles will be rendered now.

timmillwood’s picture

Status: Active » Reviewed & tested by the community

Patch working fine here.

Thanks.

acouch’s picture

I was able to get around this without doing an additional block_load here: #345050: Blocks set with context do not respect <none> block title override. Basically it is able to grab the title from the database in the get_blocks function. Let me know if this works for folks.

scor’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

The fix at #345050: Blocks set with context do not respect <none> block title override is a more generic and should address this particular case.

ggevalt’s picture

This is a patch for 7. But what about 6? This is a problem in the 6.3 version of context, yet I can't find any reference to a fix. Is this going to be fixed in 6.3?
Big problem in our minds.