Thursday, September 22, 2011

Custom Theme the maintenance ("Site Offline") page

Step 1: Override the maintenance page template

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

Step 2: Indicate in your settings.php file

specify the theme name in which u have put the maintenance-page.tpl.php in step 1

this has to be in settings.php
<?php
$conf['maintenance_theme'] = 'themeName';
?>

Step 3: Create the maintenance offline page in the case of database failure

event warnings about the database connection from appearing, copy your page.tpl.php file and rename it maintenance-page-offline.tpl.php. Change the $content variable with your custom message. Note, this template file is a template suggestion based on maintenance-page.tpl.php so they both need to exist in the same folder.

At the top of maintenance-page-offline.tpl.php, you might also want to set the following variables detailed in step 4.

Step 4: Hard code site settings

In this mode, your database is inaccessible, therefore some key settings about your site are not available. If you want this page to use the same theme and other settings that the site would normally use, you must replicate those settings by using hard-coded values.

<?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 = '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.';

?>

No comments:

Post a Comment