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)) {
return;
}
$block->module = $module;
$block->delta = $delta;
if ($module == 'block' && !empty($info) && isset($info->title)) {
$block->title = $info->title;
}
else
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)) {
to
if (!empty($info) && isset($info->title)) {
I don't know if this will break other things, though.
Comment | File | Size | Author |
---|---|---|---|
#2 | custom_block_titles-1948350-2.patch | 543 bytes | cha0s |
Comments
Comment #1
xeniak CreditAttribution: xeniak commentedActually, 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.
Comment #2
cha0s CreditAttribution: cha0s commentedYep, this one bit me. Title overrides from module-defined blocks should appear by default. Patch follows.
Comment #4
cha0s CreditAttribution: cha0s commentedI think I need to apply this against 7.x-1.x-dev
Comment #5
cha0s CreditAttribution: cha0s commented#2: custom_block_titles-1948350-2.patch queued for re-testing.
Comment #5.0
cha0s CreditAttribution: cha0s commentedCorrecting typo.
Comment #6
segi CreditAttribution: segi commentedComment #7
runeasgar CreditAttribution: runeasgar commentedThis patch does not appear to address the multilingual use case with i18n Block Translation.
Comment #8
japerryMarking needs work per #7.
Comment #9
NWOM CreditAttribution: NWOM commentedThis appears to need a re-roll or is already integrated into the module.