Where oh where did my blocks go on the 404 page?

Yesterday I received an email from one of my clients asking why the blocks weren’t showing up on a 404 page (he went to a url that did not exist). Now I had always known that Drupal doesn’t show blocks on the 404 page but I had no idea why and no idea of how to re-enable blocks on the said page.

It turns out that Drupal by design turns off blocks on your 404 page but the fix is simple. All you need to do is override the theme_page function then call phptemplate_page right after from your template.php file. If this description doesn’t make sense, don’t worry, here’s an example (put in your template.php):

function YOURTHEME_page($content, $show_blocks = TRUE) {
 $show_blocks = TRUE;
 return phptemplate_page($content, $show_blocks);
}

The fix credit for this goes to dvessel from http://drupal.org/node/129762.