2

How to turn off the notification about the site being offline, when in maintenance mode?

Operating in maintenance mode. Go online.

7

Before I give you the answer, I would suggest that you do NOT implement this.

This message is an obvious but friendly reminder that your site is in maintenance mode. Turning off this reminder may leave you scratching your head later, wondering why anonymous visitor John Smith can't access your site. The reason may be obvious to you now but it may not be so obvious as time goes by.

This code snippet removes the 'Operating in Maintenance Mode' message, but preserves other messages. Place this code in template.php and then clear the cache:

function mytheme_preprocess_page(&$vars) {
  if (variable_get('maintenance_mode', 0)) {
    $message_count = count($_SESSION['messages']['status']);
    if($message_count > 1) {
      array_shift($_SESSION['messages']['status']);
    }
    else {
      unset($_SESSION['messages']['status']);
    }
  }
}

Edit: Updated the code, this should do the trick. Added a condition that unsets the 'status' element if empty.

One last thing: The maintenance message also appears on the administration pages. You can remove this message too, but as stated earlier, this is dangerous.

The default theme for the admin pages is 'Seven', which has its own template file. You could copy the above code into Seven's template.php. Or even better, copy the code into a new function in your custom module, mymodule_hide_maintenance_message() for example, and simply call that function within mytheme_preprocess_page.

| improve this answer | |
0

Note : If you use the them omega 4.x, that function is already declared in your sub-theme (if you don't work with a sub-theme, you should) in the preprocess folder in file page.preprocess.inc

Thus you cannot add that in template.php file or you'll get WSOD. You need to edit the function in page.preprocess.inc

| improve this answer | |

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.