When a custom block is added through a module, ctools_block_content_type_render will not assign the correct block title if the original title is overridden on the block configuration page (admin/structure/block/manage/my_module/bid/configure). I discovered this issue using Panels (http://drupal.org/node/1948132).

I am using the patch from this issue; so I have the following lines in ctools_block_content_type_render:

function ctools_block_content_type_render($subtype, $conf) {
  list($module, $delta) = _ctools_block_get_module_delta($subtype, $conf);

  $info = _ctools_get_block_info($module, $delta);
  $block = module_invoke($module, 'block_view', $delta);

  if (!empty($info)) {
    // Allow modules to modify the block before it is viewed, via either
    // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
    drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $block, $info);
  $block = (object) $block;

  if (empty($block)) {

  $block->module = $module;
  $block->delta = $delta;
  if ($module == 'block' && !empty($info) && isset($info->title)) {
    $block->title = $info->title;
  if (isset($block->subject)) {
    $block->title = $block->subject;
  else {
    $block->title = NULL;

So ctools only checks for $block->$title for blocks added by the block module, but not for blocks added by other modules.

I suggest changing the line
if ($module == 'block' && !empty($info) && isset($info->title)) {
if (!empty($info) && isset($info->title)) {

I don't know if this will break other things, though.

#2 custom_block_titles-1948350-2.patch543 bytescha0s
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es). View


xeniak’s picture

Actually, using
(!empty($info) && isset($info->title)) {
means that $block->subject (the non-overridden block title) will not be used if no override title is set, since $block->title is saved as an empty string in that case.
if (!empty($info->title)) {
avoids that problem.

cha0s’s picture

Status:Active» Needs review
543 bytes
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es). View

Yep, this one bit me. Title overrides from module-defined blocks should appear by default. Patch follows.

Status:Needs review» Needs work

The last submitted patch, custom_block_titles-1948350-2.patch, failed testing.

cha0s’s picture

Version:7.x-1.2» 7.x-1.x-dev

I think I need to apply this against 7.x-1.x-dev

cha0s’s picture

Status:Needs work» Needs review

#2: custom_block_titles-1948350-2.patch queued for re-testing.

cha0s’s picture

Issue summary:View changes

Correcting typo.

segi’s picture

Issue summary:View changes
Status:Needs review» Reviewed & tested by the community
runeasgar’s picture

This patch does not appear to address the multilingual use case with i18n Block Translation.

japerry’s picture

Status:Reviewed & tested by the community» Needs work

Marking needs work per #7.