The Linux Page

Drupal blocks all disappeared!

Today I had an interesting experience... all of a sudden, all the blocks of a given theme disappeared.

It has been working just fine for months, so I really wasn't sure what the heck it could be.

The fact was that the theme was called the same as the module (as I work for a given client, I tend to do that...)

At some point, I must have added a function with a specific name and that would influence the theme. The result being blocks going bye bye!

I checked and the block content is computed just fine, the problem is the theme('block', $block) call. Although the $block->content is the HTML of the block as expected, the theme() call returns an empty string and that for all the blocks and the result is a Drupal site without any blocks.

There is the function that generates the HTML for all the blocks in a given region:

function theme_blocks($region) {
  $output = '';

  if ($list = block_list($region)) {
    foreach ($list as $key => $block) {
      // $key == <i>module</i>_<i>delta</i>
      $output .= theme('block', $block);
    }
  }

  // Add any content assigned to this region through drupal_set_content() calls.
  $output .= drupal_get_content($region);

  return $output;
}

As you can see, it will theme() the blocks. I'm still not too sure what happened, although I noticed that having the module function with name_settings() would create a form in the theme settings too. Ooops!

Anyway, renaming the theme fixed that problem. Now we may find a few other problems as I used that path quite a bit (I kept a softlink for images, etc., but there could be other things that break down...)

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.