How do I view the maintenance page without putting the site in maintenance mode?

drupal.stackexchange https://drupal.stackexchange.com/questions/250332

  •  09-01-2021
  •  | 
  •  

Вопрос

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?

Это было полезно?

Решение

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

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с drupal.stackexchange
scroll top