On the block management pages, you can specify and a title will not be created for your block. How can a similar functionality be achieved using Node Blocks? I am not able to create a node without a title as it is required, and anything I put seems to override what is on the block configuration page.

Any ideas?

Comments

meecect’s picture

sorry I tried to say above that you can specify <none> if you don't want a block title. There doesn't seem to be a way to do this with nodeblock

henrijs.seso’s picture

Hi,

You need to modify themes template.php. If you are using Zen subtheme, uncomment MYTHEMENAME_preprocess_block and place following code in it without first and last php lines

	//dsm($vars);
	if ($vars['block']->module == 'nodeblock') {
		$vars['title'] = NULL;
	}

Install devel module and uncomment dsm... line to see under hood of blocks on page.

I added text field with CCK module with title "Hide title" so my users can choose which blocks to show without title and code is as follows

	if ($vars['block']->module == 'nodeblock') {
		//dsm($vars);
		$node = node_load($vars['block']->delta);
		//dsm($node);
		if ($node->field_block_title_options[0]['value']) {
			$vars['title'] = NULL;
		}
	}

Again, with Devel module installed and dsm lines uncommented, you can see inside node and find your field and adjust code to your needs.

marcvangend’s picture

Thanks mansspams. This code does the same in D7:

function MYTHEME_preprocess_block(&$variables, $hook) {
  if ($variables['block']->module == 'nodeblock') {
    $variables['elements']['#block']->subject = NULL;
  }
}
michaellander’s picture

While this feature would be nice, currently the Drupal 6 version is only up for maintenance/security/bug fixes. I myself primarily develop for Drupal 7(though I'm going to try and make time for 6), and the other maintainers don't have the time at this time to implement nice-to-haves, unfortunately. I will however keep this in mind for future versions of Drupal 7 module, though other modules such as Display Suite sort of eliminate the need for this specific feature on Drupal 7 because you can just create another view mode.

Mansspams, thanks for helping to provide a simple solution in the meantime!

michaellander’s picture

Status: Active » Closed (works as designed)
escoles’s picture

Note that if you take the preprocess funtion approach, you will be removing node titles from ALL node blocks.

If you will have some nodeblocks where you need to display the node title, you'll do better to create a node template.

holtzermann17’s picture

Following up on #6, that's block--MODULENAME--BLOCKNAME.tpl.php -- which can be derived from block.tpl.php and put in your templates directory.

ericmaster’s picture

Version: 6.x-1.x-dev » 7.x-1.2
Category: support » feature
Status: Closed (works as designed) » Needs review
StatusFileSize
new1.69 KB

I needed this feature as well so I made a patch to provide this feature for D7, sorry I didn't have time to back port it to D6 :(

Johnny vd Laar’s picture

Status: Needs review » Needs work

I don't think your patch is made on the new dev version. The new dev version includes a new block title field. Also your patch is not according to Drupal coding standards:
$block['subject'] = $show_title?check_plain($node->title):'';

should be:
$block['subject'] = $show_title ? check_plain($node->title) : '';

Johnny vd Laar’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Needs work » Fixed

You can now change the block title from the node config, there you can leave it empty.

klonos’s picture

I tried to manually patch the latest dev version of the module with the patch from #8, but I didn't know what to do with this part:

@@ -287,8 +302,9 @@ function nodeblock_block_view($delta = '') {
 
   // Set a flag so that themes have more context.
   $node->nodeblock = TRUE;
-
-  $block['subject'] = check_plain($node->title);
+  
+  $show_title = nodeblock_type_show_title($node->type);
+  $block['subject'] = $show_title?check_plain($node->title):'<none>';
   
   $block['content'] =  node_view($node, $settings['view_mode'], $lang);

...because the mentioned existing and removed lines do not exist in the nodeblock.module file (?!).

[edit]: comment moved to #2056143: Nodeblock title not updated when node title is changed.

Status: Fixed » Closed (fixed)

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