Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Sometimes you don't want to print any title in the block and for that you set the title to .
Currently nodeblock is preprocessing the title doing check_plain() which changes the to <none> and hence when block.module checks the title and compares with '' it doesn't match.
Block.module is in charge of preprocessing the title with check_plan() it can be safetly removed from nodeblock.
Code from block.module:
// Override default block title if a custom display title is present.
if ($block->title) {
// Check plain here to allow module generated titles to keep any
// markup.
$block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
}
if (!isset($block->subject)) {
$block->subject = '';
}
Code in nodeblock.module:
$block = array(
'subject' => check_plain($node->nodeblock['block_title']),
'content' => node_view($node, $view_mode),
'#node' => $node,
);
Comment | File | Size | Author |
---|---|---|---|
#3 | nodeblock-title-none-support-2186085-3.patch | 858 bytes | nicobot |
#2 | nodeblock-title-none-support-2186085-2.patch | 860 bytes | nicobot |
Comments
Comment #1
nicobot CreditAttribution: nicobot commentedComment #2
nicobot CreditAttribution: nicobot commentedAttaching patch
Comment #3
nicobot CreditAttribution: nicobot commentedPrevious patch was not removing the title when was set.
Now attaching a complete fix
Comment #4
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedI've committed your fix here:
http://drupalcode.org/project/nodeblock.git/commit/61587af
Thanks for the help.
Comment #6
idebr CreditAttribution: idebr commentedThis patch breaks any existing hook_block_view_alter()'s. According to the API, hook_block_view should return an array containing the keys 'subject' and 'content': https://api.drupal.org/api/drupal/modules!block!block.api.php/function/h...
In the meantime, for module maintainers looking for a fix:
becomes
Comment #7
pfrenssenRaising priority and marking this against the latest release to make it easier to find for people affected by this problem after performing the update to 7.x-1.5.
Comment #8
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedIf you look inside _block_render_blocks then you'll see that the block module does have the possibility that the block_view / block_view_alter returns a title var.
This has as added behavior that you cannot override the block title from the block interface.
I'm not really decided upon whether this is a bug or that Nodeblock now uses a not documented feature of the block module.
Comment #9
darnit78 CreditAttribution: darnit78 commentedRegarding post #8, given that the documentation says that I should be able to set my block title to "" to not display the block title and that doesn't work, I would say that there is a bug here.
I'm a PHP programmer but not a Drupal programmer (and don't have time to become one today) so I don't understand the nuances of comments #6 and #8. I found the code mentioned in #6 but making that change doesn't seem to fix this issue for me. Is there a temporary fix?
Comment #10
donpwinston CreditAttribution: donpwinston commentedI just upgraded my site to 7.26 from 7.23 and in addition upgraded the nodeblock module to the latest. The "Display Block Title" checkbox no longer works. Also putting
<none>
as the title in the Blocks admin page does not work either for nodeblocks.Comment #11
iSail2 CreditAttribution: iSail2 commentedI recently upgraded to version 1.5 and the way to not show a title is to edit the node, expand the nodeblock tab, check provide block title, but leave empty the block title field that shows up. But, when the block is viewed this leaves me with empty space at the top of the block where a title would normally show up. Any suggestions as to how to remedy this?
Comment #12
caw67 CreditAttribution: caw67 commentedsame problem here. version 7.15 dont respect the !! please correct it!
Comment #13
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedOk given the number of issues people have I think it's best to release a patch. I will look into this hopefully today or tomorrow. For people that run into problems you can always try to revert the patch posted above in #4
Comment #14
jennypanighetti CreditAttribution: jennypanighetti commentedThis is urgent for me as well. Thank you Johnny for releasing an update ASAP.
Comment #15
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedOk I've committed a change here:
http://drupalcode.org/project/nodeblock.git/commitdiff/06f2d03eb0a3d888f...
Can you all verify if this helps (and reopen when needed)?
Comment #16
nmillin CreditAttribution: nmillin commentedI upgraded from 7.x-1.5 to 7.x-1.5+4-dev and it appears to have solved my issue (block title couldn't be set to
<none>
in the block interface). The workaround iSail2 described in comment #11 is no longer necessary.Comment #17
darnit78 CreditAttribution: darnit78 commentedI made the change listed in #15 and it worked. Thanks.
Comment #18
pfrenssenBit late to the party, but the patch looks good, and fixes the problem. Thanks!!
Comment #20
Matt BI'm using v1.6
I have set the block title to
<none>
, I've set the node title to<none>
, I've ticked 'provide a block title' in the node, and set it to<none>
. I've tried various combinations of these. I still get a block title displaying '<none>
'. It seems to be the title of the node is still used regardless of the block module setting for that block or the nodeblock setting. Unless I'm really mis-understanding something here I still cannot set an empty title.Comment #21
Matt BAh, looks like I had another node block module installed - it was probably conflicting....