Monday, November 25, 2013

Drupal Block Title vs. Subject

I couldn't find a post about the use of a "title" versus a "subject" in a custom block when building a module in Drupal 6. Running across this funny quirk in code and figured I'd share.

I have a module that defines a custom (navigation) block and was trying to change the title. I found that when I tried editing the title through the admin UI (

admin > build > blocks > custom block name
) nothing changed. That is the default title of the block as defined in the module was still there.

Here's how the block was defined in code:
// start navigation_block() function super_events_navigation_block($op = 'list', $delta = 0, $edit = array()) { ... $blocks = array(); switch($op){ case 'list': $block[0] = array( 'info' => t('Events Archive Navigation'), 'region' => 'right', 'status' => 1, 'weight' => 0, 'cache' => BLOCK_NO_CACHE, ); return $block; case 'view': switch($delta) { case '0': $block['title'] = t('Event Archives'); $block['content'] = theme('super_events_navigation_events'); break; } return $block; } } // end navigation_block()

Note the following line:
$block['title'] = t('Event Archives');

Apparently this works for displaying a title for a custom block, however it cannot be modified. Change this line so instead of "title" as the key you have "subject" as follows:
$block['subject'] = t('Event Archives');

Now the block's (display) title is changeable through the admin user interface.