Where is the "Site offline" page located? I would like to change it to include my graphic logo instead of the default Druplicon graphic. I'm sure it's simple, but I can't find the code that generates the page.

Comments

Zen’s picture

Look in misc/maintenance.css . The message can be configured from the settings page.

hth,
-K

PakWaan’s picture

I figured out how to replace the logo by changing the default background in maintenance.css from "druplicon.png" to my logo file.

However, the "Site Offline" wording starts in the middle of my logo - I would like to be able to move the positioning of the words an inch or two down the page - where can the positioning be changed for the text?

Patrick Nelson’s picture

It's in common.inc, line 280.

Regards

Patrick Nelson
=================================================================
All truth goes through three stages:
- First, it is ridiculed,
- Then it is violently opposed,
- And finally it is accepted as self-evident
http://www.vcommunity.org.uk

Regards

Patrick Nelson
The Webmaster Centre
UK Drupal Developers: The Webmaster Centre
Call on: 0800 197 8789 / 020 7206 2529 / 0115 896 2529

PakWaan’s picture

Line 280 in RC2 is a 403 error message.

I did find this at line 241:

/**
* Generates a site off-line message
*/
function drupal_site_offline() {
  drupal_set_header('HTTP/1.0 503 Service unavailable');
  drupal_set_title(t('Site off-line'));
  print theme('maintenance_page', filter_xss_admin(variable_get('site_offline_message',
    t('%site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('%site' => variable_get('site_name', t('This Drupal site')))))));
}

But I don't see where it would allow me to move the positioning of the variable 'site_offline_message' further down the page.

Steven’s picture

Change the margins and padding in maintenance.css to suit your taste.

--
If you have a problem, please search before posting a question.

--
If you have a problem, please search before posting a question.

PakWaan’s picture

Which CSS tag corresponds to where it places the 'site_offline_message' variable? I want to move that text about 1-1/2" down the page.

dvessel’s picture

Hey guys, I'm new to Drupal and need to do the same. I want the off-line page customized like the rest of the theme but don't want to mess with the core files.

So, is it possible to do it from the template? I searched the API docs and it seems possible. Just don't know how to implement it since I'm not a coder.

Here are a list of links I found relevant:
http://drupaldocs.org/api/head/function/_menu_site_is_offline
http://drupaldocs.org/api/head/function/drupal_site_offline
http://drupaldocs.org/api/head/function/theme_maintenance_page
http://drupaldocs.org/api/head/function/drupal_maintenance_theme

Thanks-
-joon
www.dvessel.com

joon park

dvessel’s picture

Oh, and to answer your question.. There are no tags to control the message. The lines below were generated from 4.7rc3.

<body>
<h1>Site off-line</h1>
<!-- begin content -->
This Drupal site is currently under maintenance. We should be back shortly. Thank you for your patience.
<!-- end content -->
</body>

But we do have the h1 tag which is what you want anyways. Increase the top margin to push anything below it down further.

The order goes this way margin: top right bottom left; so, in the next lines taken from maintenance.css the top margin is 1.6em.

h1 {
  margin: 1.6em 0 1.1em 0;
}

-joon
www.dvessel.com

joon park

geekarena’s picture

Isn't this a lot of unnecessary trouble? Why not just upload your logo (saved in png format) to the misc directory and rename it druplicon.png? No core or css editing needed. -- Just a thought.

VMII’s picture

Of course one could do it that way, however when the site is indexed, now you'd have someone elses logo named drupalicon which wouldn't make any real sense.

The way you are suggesting would be kinda hackish and while being a working hack, woudln't be the proper way to do it.

Your dragging upa topic a year old : ) not sure if you knew that or not.

NaX’s picture

I see nobody has actually answered this question in a way that newbies would understand. So I thought I would take a crack at it, even if it is a really old post.

In your includes/theme.inc file is a function called theme_maintenance_page().

To override the output of the default site offline page all you need to do is copy that function and its contence to your template.php file in your theme. Then rename the file to phptemplate_maintenance_page() and then any changes you make to the contents of that function will be visible and you don’t have to hack core in any way.

Here are some links to the handbook pages to help you with this.

Using Theme Override Functions http://drupal.org/node/55126
template.php: Overriding other theme functions http://drupal.org/node/11811

If you not a php developer and you don’t feel comfortable hacking php code but don’t mind using phpTemplate then here is an example of what you could do.

Use the following in your template.php file. (This is a 5.x example)

<?php
/**
 * Generates a site off-line message
 */
function phptemplate_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
 
drupal_set_header('Content-Type: text/html; charset=utf-8');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() .'misc/maintenance.css";</style>');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/defaults.css";</style>');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/system.css";</style>');
 
drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() .'misc/favicon.ico" type="image/x-icon" />');

 
$title = drupal_get_title();
 
$head_title = strip_tags($title);
 
$head = drupal_get_html_head();
 
$js = drupal_get_js();
 
$message = ($messages ? theme('status_messages') : '');
 
$html_end = (!$partial ? '</body></html>' : '');

  require_once
'site-offline.tpl.php';
}
?>

Then create the following file and save it in your theme directory (the same directory as your template.php file) as site-offline.tpl.php.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php print $head_title; ?></title>
<?php print $head; ?>
<?php print $js; ?>
</head>
<body>
<h1><?php print $title; ?></h1>
<?php print $message; ?>
<!-- begin content -->
<?php print $content; ?>
<!-- end content -->
<?php print $html_end; ?>

Now you can make changes to your site-offline.tpl.php file the same way you would make changes to your page.tpl.php file or your node-<node-type>.tpl.php files.

Hope somebody finds that useful.

btoland’s picture

Did the above on my 5.2 installation and works great.

As a newbie I had a bit of head scratching to figure out how to override maintenance.css without hacking.
Very easy in the end - just created my own css file in my theme directory and changed the misc/maintenance.css path in my mytheme_maintenance_page() function.

Many thanks!
Here's another article that might help:
http://www.mattfarina.com/2007/03/26/creating-custom-drupal-maintenance-...

KidByte’s picture

As a REALLY new user to Drupal AND PHP/CSS, this looks not only difficult, but dangerous. I think the Drupal developers should include this in their installations/maintenance routines so it can be changed by the installer. How about adding this to the "Wish List" for the next release. Should be an easy update, eh Drupal?

Kidbyte

VMII’s picture

dangerous ?

the only way something like this makes it into core is if a proper patch is created and added to the issue query by a user and it's checked over by a developer and then they choose to add it. Ideally, core is kept small for a reason. The smaller core, the smaller the footprint. Not everyone will want to change the image. Fact is if you really, really wanted to change it, you can just find it in the misc folder and replace the graphic with one of your own, naming it the same as what's already there.

NaX’s picture

This is not really that difficult or dangerous. I see how a new user that knows nothing about PHP could find this very scary, but it’s not dangerous. Because you are only changing your theme for one page that is not always visible, it has no real impact on your site. Generally you would test things like this before you make them live. If you follow the instructions exactly the PHP stuff is just a copy past. When it comes to the site-offline.tpl.php file you can do what ever you want. You can make it a static html file without all the embedded PHP stuff. The template.php file is at the heart of drupals theme system, without it themers loose a lot of flexibility.

But I see where you are coming from, drupal is not that easy to use if you don’t really know PHP. You can do a lot if you stick to the contrib themes and modules but if you want to do more than what’s already available, then knowing PHP becomes important. Maybe thats why many developers see drupal as a framework, rather than an out the box CMS, but this is slowly changing. You can see this in the changes to the theme system (http://drupal.org/node/132442).

f1vlad’s picture

It must be mentioned, as it's not quite clear or obvious, that when you perform this template override, you require to go to ~/admin/settings/site-maintenance and bounce your site back to online mode then again to offline mode. Only then _will_ your changes will take effect.

Bartezz’s picture

subscribing

________________
Live fast die young

alienresident’s picture

Here is a updated version to use in a Zen subtheme's template.php

<?php
function zen_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
 
drupal_set_header('Content-Type: text/html; charset=utf-8');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. path_to_subtheme() .'/maintenance.css";</style>');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/defaults.css";</style>');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/system.css";</style>');
 
drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() .'misc/favicon.ico" type="image/x-icon" />');

 
$title = drupal_get_title();
 
$head_title = strip_tags($title);
 
$head = drupal_get_html_head();
 
$js = drupal_get_js();
 
$message = ($messages ? theme('status_messages') : '');
 
$html_end = (!$partial ? '</body></html>' : '');

  require_once
'site-offline.tpl.php';
}
?>

Note: I am using a local version of the maintenance.css in my theme folder by calling path_to_subtheme()
So in my theme folder I have added the code to template.php
I have a new file called maintenance.css with my custom css
I also have a new file site-offline.tpl.php with my custom page info as in NaX's comment

jwilson3’s picture

This version fixes a problem with relative paths returned from path_to_subtheme() when the maintenance page is shown for internal site pages.

I've also added a snippet to the end of the $content that refers the user to a Google cached version of the requested page if its a node or the frontpage.

<?php
/**
 * Implementation of theme_maintenance_page().
 * See http://drupal.org/node/58562#comment-1238366
 */
function zen_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
 
drupal_set_header('Content-Type: text/html; charset=utf-8');

 
drupal_set_html_head('<style type="text/css" media="all">@import "/'. path_to_subtheme() .'/maintenance.css";</style>');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/defaults.css";</style>');
 
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/system.css";</style>');
 
drupal_set_html_head('<link rel="shortcut icon" href="/'. path_to_subtheme() .'/favicon.ico" type="image/x-icon" />');

 
$title = drupal_get_title();
 
$head_title = strip_tags($title);
 
$head = drupal_get_html_head();
 
$js = drupal_get_js();
 
$message = ($messages ? theme('status_messages') : '');
 
$html_end = (!$partial ? '</body></html>' : '');
  if (
arg(0) == 'node') {
   
$google = "http://google.com/search?q=cache%3A";
   
$home_page = $google . $_SERVER['HTTP_HOST'];
   
$this_page = $home_page . request_uri();
   
$content .= '<div class="cached-version">';
    if (
request_uri() != '/') {
     
$content .= t('You may also wish to view a <em>cached version</em> of <strong><a href="!this_page">this page</a></strong> or <strong><a href="!home_page">our homepage</a></strong> from Google.',array('!this_page' => $this_page, '!home_page' => $home_page));
    }
    else {
     
$content .= t('You may also wish to view a <em>cached version</em> of <strong><a href="!home_page">our homepage</a></strong> from Google.',array('!home_page' => $home_page));
    }
   
$content .= '</div>';
  }
  require_once
'site-offline.tpl.php';
}
?>

Alternatively, you could leave the template.php code as is, and place the Google Cache link stuff in the site-offline.tpl.php file if you dont need to worry about translatable strings....

<!-- begin content -->
<?php print $content; ?>
<!-- end content -->

<?php if (arg(0) == 'node') : ?>
<?php
$google
= "http://google.com/search?q=cache%3A";
$home_page = $google . $_SERVER['HTTP_HOST'];
$this_page = $home_page . request_uri();
?>

<small>
You may also wish to view a <em>cached version</em> of
<?php if (request_uri() != '/') : ?>
<strong><a href="<?php echo $this_page ?>">this page</a></strong> or
<?php endif; ?>
<strong><a href="<?php echo $home_page ?>">our homepage</a></strong>
from Google</a>.
</small>
<?php endif; ?>

<?php print $html_end; ?>

doublesix’s picture

Hey, don't know if this is good or bad but I wanted a somewhat fancier "coming soon" page with some links, etc.

My solution was to create a simple html page, outside the drupal framework, then change these lines (323,324) in common.inc ...

  print theme('maintenance_page', filter_xss_admin(variable_get('site_offline_message',
    t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))))));

to ...

  header('Location: /where/your/file/is.html');

hope that helps someone.

VMII’s picture

hacking a core file, even if minimally is frowned upon. Each and every update or upgrade you would have to make the same adjustment to core code. Thus avoiding doing this as above is advised.
_____________________________________________________________________
Confucius says:
"Those who seek drupal answers should use drupal search!" : )

NaX’s picture

You can do this without hacking core by modifying the example in http://drupal.org/node/58562#comment-266358

Here are 2 possible examples ways of doing this.

Include your html file, that should be in your theme dir

<?php
function phptemplate_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
  require_once
'site-offline.html';
}
?>

Redirect to your html file.

<?php
function phptemplate_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
  
header('Location: /where/your/file/is.html');
}
?>

But I would recommend using drupals redirect function. See http://api.drupal.org/api/function/drupal_goto/5

drupal_goto('/where/your/file/is.html');
doublesix’s picture

Thank you, this worked very nicely. For any other total beginners I'll point out NaX's code goes into a (new) file in your templates directory called template.php ... that one took me a while to figure out.

Drupal continues to be a learning experience .. thanks again.

VMII’s picture

some themes already have a template.php, if your theme doesn't have a template.php you create one.
_____________________________________________________________________
Confucius says:
"Those who seek drupal answers should use drupal search!" : )

krunar’s picture

hi,

i have done exactly as you suggested but i still get the same page.
I am using 5.7.
Any ideas what can be the error?

My first one: www.inkjetshops.gr

krunar’s picture

hi,
i finaly made it work and thank you for the help.

Just one small tip which might not be so important
if you use
header('Location: /where/your/file/is.html');
or
drupal_goto('/where/your/file/is.html');

then you are redirected in the offline page.
If in the mean time the site comes online and you refresh your page you will still see the offline message since you url points to the offline page.
if you use
  require_once 'site-offline.html';
you dont have such problem so i think this method is better.
small a stupid maybe but it got me confused for a second

My first one: www.inkjetshops.gr

Lisa Williams@drupal.org’s picture

I tried adding this to template.php, but no luck, so I reverted to my original template. php file and made do by simply changing what the logo in maintenance.css points to and using the ability to add a message in the "Site maintenance" window.

Strange thing, even though I've reverted to my old template.php, the changes I make aren't coming through in my browser, despite the fact that when I look at it on another machine it's fine.

What do I have to do to be able to see my newly-edited maintenance mode page on my own machine?

Thanks, all -- LW

NaX’s picture

Try following this example http://drupal.org/node/58562#comment-266358

Also have a look at this docs page that references this thread. http://drupal.org/node/235463

But it sounds like you have a browser cache problem.

jeremdow’s picture

The maintenance page is cached in cache_page if you have you have that enabled in Performance.

Truncate that table or whatever you use to clear the site cache.

tille’s picture

for the 5.3-update I finally also need to set some pages to offline - and of course I would also like to have a themed off-page..:] ..I actually already found what I was looking for (the theme_function will do) but still couldn't resist to suggest if this 'link/to/offline/page.html' could also be a nice feature for upcoming drupal versions.. There is already the "front page" option provided by the front-page-module - why not make it a core functionality to have an alternative "online start page" and an "offline start page"..? I would just love to see such a feature in dp-6, 7, 8...:]

greetz, till..

___________________________
my pictures: www.bilderbook.org

___________________________

darumaki’s picture

On localhost site-offline.tpl.php works but on the server it's not displaying the offline message even though the files are the same

jfall’s picture

Two excellent methods for doing this!

I created a small handbook page to document these two approaches: http://drupal.org/node/235463

ishmael-sanchez’s picture

With Drupal 6 if you create a maintenance-page.tpl.php (Based on your theme's page.tpl.php) and go to sites/default/settings.php (Make writable if necessary).
And Around line 170, update the code:
$conf['maintenance_theme'] = 'themename';//

You should be all set, and you can make any customizations to the template file as needed.