how can i define a maintenance template within a custom module? i have done this within a module for defining custom templates when having status error 

function custom_module_preprocess_region(&amp;$vars) {

  $header = drupal_get_http_header('status');

  if( $vars['region'] == 'content' ) {
if ($header == '404 Not Found') {
  $vars['theme_hook_suggestions'][] = 'content__404';     
}
if ($header == '403 Forbidden')  {
  $vars['theme_hook_suggestions'][] = 'content__403';
}
 }
 }

 function custom_module_theme() {
   return array(
'content__404' =&gt; array(
  'template' =&gt; 'region--content--404',
  'variables' =&gt; array('xxx' =&gt; null),
  'path' =&gt; drupal_get_path('module', 'custom_module').'/templates'
),
'content__403' =&gt; array(
  'template' =&gt; 'region--content--403',
  'variables' =&gt; array('xxx' =&gt; null),
  'path' =&gt; drupal_get_path('module', 'custom_module').'/templates'
),
'maintenance' =&gt; array(
  'template' =&gt; 'region--content--maintenance',
  'variables' =&gt; array('xxx' =&gt; null),
  'path' =&gt; drupal_get_path('module', 'custom_module').'/templates'
),
 );
 }


How can i implement it just the same to override the theme maintenance tpl ?
drupal_get_http_header() should be treated as deprecated.

See https://www.drupal.org/node/1969270#comment-7609337

I think your approach is good, but for a little more coverage of 404/403 pages we came up with a more extendable approach, also theres a bit more room for customization in the backend within the modules settings page.

We did this by using the customerror module in conjunction with a theme function and a few overriding template files.

https://www.drupal.org/project/customerror

After installing, add this to your template.php file's theme_preprocess_page function. Example;

function YOURTHEME_preprocess_page(&amp;$variables) {

  $alias_parts = explode('/', drupal_get_path_alias());

  if (count($alias_parts) &amp;&amp; $alias_parts[0] == 'customerror') {
    if ($alias_parts[1] == '403') {
      $variables['theme_hook_suggestions'][] = 'page__forbidden';
    }
    if ($alias_parts[1] == '404') {
      $variables['theme_hook_suggestions'][] = 'page__not_found';
    }
  }

  &lt;other code goes here&gt;

}


Then in your templates folder add your custom templates (just like your page.tpl.php file);


page--forbidden.tpl.php
page--not-found.tpl.php


Clear your cache, hit one of those pages (you can test them by going to);


[yoursite]/customerror/403
[yoursite]/customerror/404


As for your maintenance page, all you need to do is create a 
maintenance-page.tpl.php file and toss that in your templates folder.