2

I've just been asked by the stakeholder of a site I'm working on how he can view the maintenance page of his site so he can test links on it without putting the site in maintenance mode.

I'm going to suggest that we do this in a lower environment, since the info is the same but is there any way to do this?

3

By default there is no route to access the maintenance page via url. You can create a menu item and the corresponding page callback in your module :

// Access maintenance page regardless of the maintenance mode. 
$items['maintenance'] = array(
  'title' => 'Maintenance',
  'page callback' => 'yourmodule_maintenance_page',
  'access callback' => 'user_is_logged_in',
  'type' => MENU_CALLBACK
);

yourmodule_maintenance_page () {
  // Just use the internal status code to make Drupal load the apropriate theme and template. 
  return MENU_SITE_OFFLINE;
} 

And that's all, go to /maintenance to see the page.

You may also want to override the 'maintenance_page' theme, have a look at :

  • the base preprocess function in includes/theme.maintenance.inc
  • base template file in modules\system\maintenance-page.tpl.php
2

Another way to do it is to add the following code to your settings.php file

if (isset($_GET['maintenance'])) {
   $conf['maintenance_mode'] = TRUE;
}

Then go-to 'your_domain/?maintenance=1' and you'll be in maintenance mode.

1
  • This works nicely. But IMHO it should only be used in development environments not in production.
    – osman
    Apr 12 '18 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.