Theming the Drupal 6 maintenance page
The maintenance page is used when the site is set into off-line mode or site is inoperable due to technical problem such is database server not working. You can enable this mode from "Administer > Site configuration > Site maintenance". This mode will also trigger with a database failure. By default, the core theme Minnelli is used in this mode even if another theme is selected. To use your theme for the maintenance page, it has to be set from your "settings.php" file located in either "sites/default" or "sites/your.domain.com".
From that file, enable it through the $conf variable with the internal name of your theme:
<?php
$conf['maintenance_theme'] = 'themeName';
?>Instead of adding the line above to the settings.php file, you can also uncomment (remove the hash at the start of the line) the relevant lines in settings.php. In that case, you have to uncomment 3 separate lines :
- the array declaration (
# $conf = array() - the maintenance theme setting (
# 'maintenance_theme' => 'minnelli',) - the closing parenthesis (
# );)
Next, copy your main "page.tpl.php" and rename it to "maintenance-page.tpl.php" or copy the template located in "modules/system/maintenance-page.tpl.php" to your theme and edit so it matches the rest of your site. Verify the changes by setting the site into off-line mode then log out.
To account for database failures, try turning off your database. Any function call that depends on the database should be checked first with db_is_active. The variable $db_is_active can also be used from the template. As an alternative to disabling your database, force a database connection failure. Examples for both methods here.
To prevent warnings about the database connection from appearing, you can also place a template file named "maintenance-page-offline.tpl.php" and change the $content variable with your custom message. This template file is a template suggestion based on maintenance-page.tpl.php so they both need to exist.
You might also want to set:
$head_title- the value used in the HTML <title> tag. Defaults to "Site off-line | Drupal"$site_name- value used in the page's <h1> tag. Defaults to "Drupal". If "Site name" is turned off in your theme configuration, then you'll want to clear this variable (see example below).$logo- if you're using a custom logo override in the theme settings. Use the full path of the custom logo, relative to the base directory of the Drupal installation. If you used the standard override upload function in the theme configuration for your custom logo, your logo will be stored insites/all/files/(see example below).$site_slogan- Your site's slogan. If "Site slogan" is turned off in your theme configuration but you still have a site slogan defined in Site Information, then you'll want to clear this variable (see example below).
Example additions at the top of maintenance-page.tpl.php:
<?php
$head_title = 'mysite.com :: Site-offline';
$logo = 'sites/all/files/customLogo.png';
// If your theme is set to display the site name, uncomment this line and replace the value:
// $site_name = 'Your Site Name';
// If your theme is set to *not* display the site name, uncomment this line:
unset($site_name);
// If your theme is set to display the site slogan, uncomment this line and replace the value:
$site_slogan = 'My Site Slogan';
// If your theme is set to *not* display the site slogan, uncomment this line:
// unset($site_slogan);
// Main message. Note HTML markup.
$content = '<p>The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.</p><hr /><p>If you are the maintainer of this site, please check your database settings.</p>';
?>A "maintenance.css" file is included in this mode. It is located in "modules/system/maintenance.css". You can override this file with the instructions provided in the style sheets section.
Notes:
- The initial install and updating of your site depends on the core themes, Minnelli and Garland. It cannot be changed for these modes.
- The theme registry is not cached when set to off-line mode.
- Ensure that the theme used as maintenance theme is enabled (Administer > Site building > Themes).

Theming the Drupal 6 maintenance page-drupal.org/node/195435
I am new to Drupal, so I am probably making a mistake. I am trying to change the Theme of my Drupal 6 maintenance page so that it matched the theme (mytheme) that I am using for my site (Theming the Drupal 6 maintenance page - http://drupal.org/node/195435).
I tried to followed the instructions shown in http://drupal.org/node/195435. Here are the problems that I had:
1. Got message that sites/default/settings.php was password protected so that I could not make changes to this file. So I made changes to the sites/default/default.settings.php. However, when I went to upload the modified file onto my server, I received a message indicating that sites/default/ was locked and thus would not accept this modified file.
2. Am I to save the new file maintenance-page.tpl.php in theme/mytheme or write over the file located in modules/system?
3. I could not find any directions as to how to modify modules/system/maintenance.css. I assume that I should take my style.css (in theme/mytheme), rename it maintenance.css then write over the file located in modules/system. Is this correct?
However, since I could not perform 1 above, I am still using the default ("minnelli") maintenance page.
Any assistance is much appreciated! Thanks!
The settings.php file is
The settings.php file is write protected for security reason. You need to temporarily turn on write permission to that file to make change. On Unix/Linux you would do
chmod u+w settings.php, edit/save, thenchmod u-w settings.php.-Drupal Notebook-
hi, how do you turn off the
hi, how do you turn off the database?
thanks.
Always, Anne
Re: how do you turn off the ...
Do you mean "turn off the theme & turn on the maintenance page" or "turn off the maintenance page"?
I guess...
I guess you mean "how do I turn off the database to see what happens to my site". In order to do that, you really would need full server access, it usually cannot be simulated with typical shared hosting plans.
On a dedicated server: if you use the Plesk control panel, you can go to Server -> Services and switch off MySQL. Don't worry about Plesk, it runs on its own DB-server and own Webserver, so whatever happens, Plesk should remain accessible. If you don't run a control panel, you need to log in as root via SSH (or do it locally in the terminal if you have physical access to the server). Then issue
/etc/init.d/mysqld stopThe Database server will shut down and tell you so. Now you can test your Drupal installation and test what happens if no DB-server can be found any more. The normal and unaltered behaviour of Drupal is to spit out a page in the standard maintenance design saying that such and such database on server such and such with username such and such (sic!!!) is not available.
Thanks god Drupal does not tell the database password!!! This is a good ment feature for the site admin in case things go wrong (like the DB server died by some reason) but it is a bit awkward on public and live sites where such things might also happen... I mean you don't get far with this information, but non-the-less, the general public now knows where the database server is located, what Drupal's database is called and which username is chosen to access the server... :-(
This is basically the reason why DB-offline maintenance themes should be done on larger scale sites. To provide a clean information that something has gone wrong. :-)
After your test (seeing if your new DB-offline page actually works in such situations), don't forget to switch back on the DB-server, either using Plesk or on the command line with
/etc/init.d/mysqld startJust as a note: should in your distro the terminal tell you that there is no file in /etc/init.d called mysqld, you might want to search for it on the machine, it will usually be somewhere in a subdirectory that controls the services to start upon system startup. On some Linux systems, there is the even more elegant command
service mysql stopand
service mysql startSimulating database failure to test maintenance-page-offline
Instead of actually disabling the database, you can just intentionally cause a failed connection.
Do this by making the connection string invalid in
settings.php:$db_url = 'x';
This should cause a failed database connection and invoke the
maintenance-page-offline.tpl.phpfile.When you're done testing, remove that code. It should set everything back to normal.
http://kentrichards.net
You can change permissions to settings.php another way...
You can change permissions to settings.php another way (if, like me, you don't get involved with all that unix/linux voodoo).
- Log in to your cPanel or file manager
- Find sites/all/default/settings.php
- The file permissions are probably set to 0644.
- Change these to 0777 and you can overwrite the file.
- Remember to change them back to 0644 afterwards.
Using the same color scheme for website and maintenance page
Hi everyone!
I managed to change the maintenance theme to Garland by modifying the "settings.php" file as described above (http://drupal.org/node/195435).
However, the appearance of the off-line maintenance site is still different as the on-line color scheme - specified within the color module - is not reflected.
Instead the standard blue lagoon appearance is shown on the screen.
Is there any simple way of adapting this?
I just would like to use the same color settings for the maintenance theme as for the standard theme - nothing sophisticated so.
I have been searching for several days now, but I still do not have any clue on how to achieve this.
Probably, this can be done fairly easy by copying a stylesheet file somewhere... (I am new to Drupal, sorry!)
Any help would be much appreciated. Thanks a lot!
The problem is the color
The problem is the color settings are *not* processed for the maintenance page. You can make a little modification to Garland to make the color change happen. In Garland's template.php, add this function:
<?phpphptemplate_preprocess_maintenance_page(&$vars) {
phptemplate_preprocess_page($vars);
}
?>
This will work for site off-line mode. But it will not work when database is not working. To get that working also, you will need to set the variable 'color_garland_stylesheets' array in $conf[] inside settings.php to reflect your current color module settings and you need to edit that everytime you make color change.
To learn more about maintenace page theme, see http://www.hddigitalworks.com/custom-site-off-line-page
-Drupal Notebook-
Modification did not have any effect
Thank you for the quick reply!
I had to add the word "function" in the declaration part. I guess that is okay, because otherwise Drupal returned an error message.
Unfortunately, the added function did not have any effect - I still get the Blue Lagoon appearance of the maintenance theme.
Am I missing anything?
Concerning your second remark, what exactly do I have to specify for 'color_garland_stylesheets' inside "settings.php"?
$conf = array('color_garland_stylesheets' => 'sites/default/files/color/garland-f2968754/style.css',
);
Apart from the stylesheet path, I also tried the respective color values and a boolean variable so far. However, none of them seemed to work as I always get some kind of error message even with the database still working.
~
change the function to:
<?phpfunction phptemplate_preprocess_maintenance_page(&$vars) {
if (function_exists('_color_page_alter')) {
_color_page_alter($vars);
}
}
?>
This will work for site off-line mode. However, I haven't found a way to make it work for database is off case. It will still be in the default color scheme.
-Drupal Notebook-
Great! That worked for site off-line mode.
Thank you very much for your help!
Concerning the case when the database is offline, you made the following remark some posts earlier:
"This will work for site off-line mode. But it will not work when database is not working. To get that working also, you will need to set the variable 'color_garland_stylesheets' array in $conf[] inside settings.php to reflect your current color module settings and you need to edit that everytime you make color change."
As I am not planning to make frequent (perhaps not even any) color changes, I would like to try setting the variable 'color_garland_stylesheets'. However I do not know which value to assign - stylesheet path, color values, etc.
Have you got any idea on this? Sorry for bothering you again...
core?
Thank you for this information, this is very helpful!
Still, it seems to me it should be a lot easier to have your maintenance page connect with your site's theme. Any plans for this functionality to become core -- e.g., so admins can chose a site maintenance theme without having to do anything to the php? I will submit a feature request as well.
thanks
~
>it seems to me it should be a lot easier to have your maintenance page connect with your site's theme
This is pretty much impossible because maintenance page need to work when the database is offline. With the database gone, drupal basically have to work in its most primitive mode and all normal settings information are not available. The only facility have in that case is settings.php and there no way around it.
-Drupal Notebook-
Good information - thanks MrBailey
I have a couple of doc improvement suggestions:
Can you break it down into steps more clearly?
And separate the simple first stages (settings.php and maintenance-page.tpl.php) from the more complex that follow?
Subheadings would help with structure.
I managed to make my offline message look more like I want it. So, thank you.
Fatal Error
Hello,
I tried to change the theme for the off-line maintenance page according to http://drupal.org/node/195435
I added one line to the sites/default/settings.php file
<?php $conf['maintenance_theme'] = 'nitobe'; ?>but got the error message:
Fatal error: Cannot redeclare gnf2() (previously declared in /home/mypage/public_html/index.php(1) : eval()'d code:1) in /home/mypage/public_html/sites/default/settings.php(1) : eval()'d code on line 1
After I removed the statement again from the settings.php file I still have this error message and cannot access my page anymore.
I hope somebody can help me out! I am at the end of my wisdom.
Thanks!
Roger
.
Check your setting.php file permissions. Make sure it's actually still writable. Apparently you're not overwriting the one up on your server.
Is there any new easy way to change the mySql page ?
Thank you, but is there any new easy way to change the mySql unable to connect page now ?
I tried to to it the way it is explained here and got an error:
Parse error: syntax error, unexpected T_FUNCTION in /sites/default/settings.php on line 241
Any help ?
Thanks a lot.
Believe it or not, this
Believe it or not, this method is very very easy. It's just a tad bit confusing at first (I was for one), due to the way it's explained on here.
So I'm just gonna go bare ones here. The only thing you're doing to the setting.php is the following:
Open up the settings.php file in something like Dreamweaver (i'm gonna go by line numbers).
On line 184, which contains: # $conf = array(
You remove the "#".
You then skim through and move on to line 196, which contains: # 'maintenance_theme' => 'minnelli',
You remove the "#".
And in place of "minnelli", you place the name of *your* theme. Which is where you want your customized maintenance-page-offline.tpl.php file in, so that you're able to to use it for database errors or unable to connect to a database etc.
You then skim through and move on to line 225, which contains: # );
You remove the "#".
Save settings.php and upload it viat ftp, but before you do, again make sure the current file up has it's file permission set to something like "777", so that you're able to save your new version.
Tada, you're done. It's really simple actually. It just seems complicated or confusing at first, due to being a bit unaware of how things function.
And if you want to see if it's working, as suggested above, simply place:
$db_url = 'x';
on the last line of settings.php
Once you're done testing that it works, don't forget to remove that line.
Friendly reminder: once you upload of the newer file and after you're done editing it, be sure to revert it's file permission to the way they were originally, which should have been: "444".