Drupal Maintenance Page drupal-maintainance Full view

Drupal Maintenance Page

Here will we go through how we can enable and create our own custom drupal maintenance page.

I’ll explain it with an example. So now lets get started….

Enable Site maintenance page

  1. Enable Off-line under ‘site status’ in “/admin/settings/site-maintenance” page
  2. If boost is enabled, cleared all the boost cached content for the change to reflect immediately
  3. If varnish is enabled for apache, restart the varnish server for the change to reflect immediately
  4. All the pages except “/user” will show up ‘Site offline” page

Now we have enabled our site maintenance page. Now we can go to our next step i.e. creating custom maintenance page

Maintenance page:

The default maintenance page theme is minnelli(garland).
There are 2 types of maintenance page:
  1. maintenance-page.tpl.php
    This page is shown up only when the application is in the maintenance mode and able to access the db
  2. maintenance-page-offline.tpl.php
    This page is shown up when the application is not able to access db, eg, due to wrong db name in the settings.php, or $db_url = ” in settings.php, or if the db server is down etc.
If no maintenance tpl in the custom theme folder then the tpl’s from /themes/garland/maintenance-page.tpl.php is used.

Steps to create custom maintenance page:

  1. Make a copy of page.tpl.php in the custom theme folder and rename it as maintenance-page.tpl.php
  2. Make necessary changes to the tpl file
  3. In settings.php file, include the key ‘maintenance_theme’ to the $conf variable with the value assigned to the custom theme name .
    $conf = arrray(‘maintenance_theme’=>’custom_theme_name’);
In case of maintenance-page-offline.tpl.php file, the file will not have access to the db, so the some of the variables will not be populated. In that case, hard code the values for the variables used in the tpl file.
$logo = “/sites/all/custom_theme/images/logo.png”;
$site_slogan = “Site Name”;
$content = "The site is currently not available due to technical problems. Please try again later. Thank you for your understanding. If you are the maintainer of this site, please check your database settings.";

Add css to the maintenance page:

3 ways to add css
  1. The maintenance page html will have body tag will have in “in-maintenance” class. So if the style changes are very minimum, then include the “.in-maintenance” for the necessary changes in the style.css file or any other existing css file.
  2. Include in the maintenance-page.tpl.php file
  3. Add a new preprocessor in the template.php file
function THEMENAME_preprocess_maintenance_page(&$vars) { 
drupal_add_css(path_to_theme() . '/relative/path/to/style.css', 'theme'); 
$vars['styles'] = drupal_get_css(); 
} ?>

*for more information follow this link Maintenance Page

Written by gsjha

I am developer plus designer. I love to code and design cool stuff and also I keep on digging new stuff. I have my profile on behance-gsjha

Related Articles