Hello,
I'm trying to add a custom maintenance.css to my zen subtheme. I copy the maintenance-page.tpl.php to my template folder and add the maintenance.css to my theme .info file but the maintenance.css seams to affects all pages (not only off-line page) in google chrome and don't run at all with IE. I try to understand what's wrong by read some forum issues, but I'm really confused. I edit my setting.php file and my maintenance page is running but i can edit the style.
Sorry for my poor english, I know that there are many topics about this but I can't understand ...
Thank you

Comments

roper.’s picture

Any stylesheet you add to your theme's .info file is supposed to be loaded on every page, that's how it's designed.

The reason it's not showing up in IE is probably because you have CSS aggregation disabled at "/admin/settings/performance" in which case IE fails to load anything over 31 stylesheets. If you enable aggregation (which you should always do on a production site), you should see your stylesheet in IE.

If you only want your stylesheet on the maintenance page, remove it from the .info file. Then you can do one of three things:
1. If you don't have too many styles, just prefix them with body.in-maintenance in your main CSS file.
2. Just hardcode <link rel="stylesheet" href="/path/to/style.css" /> in your maintenance-page.tpl.php file.
3. Add a new preprocessor to your template.php file:

function THEMENAME_preprocess_maintenance_page(&$vars) {
  drupal_add_css(path_to_theme() . '/relative/path/to/style.css', 'theme');
  $vars['styles'] = drupal_get_css();
}

:)

silvia ruggeri’s picture

Thank you for the answer,
can you explain me how to hardcode
in my maintenance-page.tpl.php file?
I know nothing about php :-(
Can I do the same for maintenance-page-offline.tpl.php?
Thank you very much for your help

I add this lines at the top of my maintenance-page.tpl.php file:

<?php
$styles = '<link rel="stylesheet" href="sites/all/themes/codesalight/css/maintenance.css" />';
?>

Is it right?

mndonx’s picture

No need to use php there - the tpl file is like regular HTML file, just with some php injections of page variables. So you can paste:

<link rel="stylesheet" href="/path/to/style.css" /> into the <head></head> section of the tpl file. And, yep, you should be able to do the same in the offline tpl file.

Let me know if that helps.
Amanda

roper.’s picture

This is correct, and it might be a good idea to put it below the <?php print $styles; ?> that should already be in your tpl. That way your CSS rules would take precedence over rules that may already exist in other stylesheets.