Hi,

I'm puzzled by the following behavior: if I move a menu block which I created to appear in a sidebar region to the content area, then the title (which I've overridden) appears. If that same block appears in the sidebar, the title does not appear. It's not hidden by CSS - it's simply not present at all in the source for the block.

Has anyone encountered this before?

Thanks,
Lee

Comments

LNakamura’s picture

I added a couple of strategic drupal_set_message() statements and have discovered the following: from the perspective of menu_block_block_view($delta = '') in sites\all\modules\menu_block\menu_block.module, the block title is present both times the block is rendered after menu_tree_build($config) has been called. However, by the time the sidebar block (only) is rendered in modules\block\block.tpl.php, the title is no longer present - thus the following conditional fails, and the drupal_set_message() I added (as well as the printing of the title, of course) is never hit:

<?php if ($block->subject): 
drupal_set_message(t('In block.tpl.php - subject: [%x]', array('%x' => $block->subject)), 'status');  
?>
  <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>

Anybody have a clue as to what would cause this behavior?

LNakamura’s picture

I ended up overriding block.tpl.php (as block--menu-block.tpl.php) so I could modify it in this way:

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); 
  // LEN begin added:  
  $config = menu_block_get_config($block->delta);
  $data = menu_tree_build($config);
  $title = $data['subject'];
  //drupal_set_message(t('LEN In block--menu-block.tpl.php - title: [%x]', array('%x' => $title)), 'status'); 
  // LEN end added 
  ?>
<?php if ($block->subject): 
  // LEN begin added:
  drupal_set_message(t('LEN In block--menu-block.tpl.php - subject: [%x]', array('%x' => $block->subject)), 'status');  
  // LEN end added
?>
  <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php // LEN begin added: ?>
<?php else:  
  drupal_set_message(t('LEN In block--menu-block.tpl.php - had to get title: [%x]', array('%x' => $title)), 'status');  
?>
  <h2<?php print $title_attributes; ?>><?php print $title ?></h2>
<?php // LEN end added  ?>
<?php endif;?>
  <?php print render($title_suffix); ?>

Still hoping someone might have some insight into why this was necessary in the first place...

Thanks,
Lee

JohnAlbin’s picture

Category: bug » support
Status: Active » Closed (works as designed)

The block title is a configuration provided by the block module. It is configurable per block per theme. And its not related to the menu_block module.