Drupal 6 maintenance mode missing head elements

Posted on 19 January 2012 by jose

Yesterday, I blacked out my site in protest of SOPA and PIPA. I figured the easiest way to do so was to create a quick custom theme just for the occasion, a minimalist theme inspired by BoingBoing's own SOPA Strike page. Further, I would switch my site to its offline mode, which meant I had to have a working maintenance page template.

I had a couple of options here: Zen, my subtheme's parent, already had a maintenance-page.tpl.php file in its templates directory. I could also grab the default Drupal maintenance template from the /modules/system directory. In either case, I noted that the HTML HEAD element was to be populated, as is usual, by printing the $styles, $scripts, $head, &c. variables.

But once I had the theme in place and the CSS ready, I discovered that my maintenance page was not using the layout and colors I'd selected. It was as if the maintenance template file was ignoring those variables I mention in the previous paragraph. From looking at the Drupal API site, it seems my themes (once based on Marinelli, another on Zen) were not actually generating their variables for the maintenance page as described in the maintenance preprocessor.

This left me with an empty <head> block in my HTML source; the $styles variable in particular was not being populated by the drupal_get_css function, so none of my styles were actually being applied. I opted to add the maintenance preprocessor function, though much more reduced in scope, to generate the basics for the page. I imagine it's possible my themes (or my sites) are somehow misconfigured, thus keeping the maintenance theme from functioning properly, but that's an investigation for another day. For now, I've got a functioning maintenance page that conforms to my theme's look and feel without my having to hard-code any references to my stylesheets.

Latest poll

Which do you favor?