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,
  );
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nicobot’s picture

Issue summary: View changes
nicobot’s picture

Attaching patch

nicobot’s picture

Title: Title <none> doesn't work » Can't set empty title
FileSize
858 bytes

Previous patch was not removing the title when was set.
Now attaching a complete fix

Johnny vd Laar’s picture

Status: Active » Fixed

I've committed your fix here:
http://drupalcode.org/project/nodeblock.git/commit/61587af

Thanks for the help.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

idebr’s picture

Status: Closed (fixed) » Needs work

This 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:

 $data['subject'] = '...';

becomes

$data['title'] = '..'
pfrenssen’s picture

Version: 7.x-1.x-dev » 7.x-1.5
Priority: Normal » Major

Raising 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.

Johnny vd Laar’s picture

Assigned: nicobot » Unassigned

If 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.

        // 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);
        }

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.

darnit78’s picture

Regarding 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?

donpwinston’s picture

I 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.

iSail2’s picture

I 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?

caw67’s picture

same problem here. version 7.15 dont respect the !! please correct it!

Johnny vd Laar’s picture

Ok 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

jennypanighetti’s picture

This is urgent for me as well. Thank you Johnny for releasing an update ASAP.

Johnny vd Laar’s picture

Status: Needs work » Fixed

Ok 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)?

nmillin’s picture

I 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.

darnit78’s picture

I made the change listed in #15 and it worked. Thanks.

pfrenssen’s picture

Bit late to the party, but the patch looks good, and fixes the problem. Thanks!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Matt B’s picture

Version: 7.x-1.5 » 7.x-1.6
Status: Closed (fixed) » Needs work

I'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.

Matt B’s picture

Version: 7.x-1.6 » 7.x-1.5
Status: Needs work » Closed (fixed)

Ah, looks like I had another node block module installed - it was probably conflicting....