I need to add two css files, a front-page.css for the frontpage and an admin.css for all the admin pages.
I had a look to the following code I found in the template.php file:
<php?
// Example: optionally add a fixed width CSS file.
if (theme_get_setting('STARTERKIT_fixed')) {
drupal_add_css(path_to_theme() . '/layout-fixed.css', 'theme', 'all');
}
?>but I couldn't figure out how to use it to add the front-page.css and the admin.css files.
So I used the following snippet which works pretty well (see http://drupal.org/node/225868):
<?php
function mytheme_preprocess_page(&$variables) {
$front_style = path_to_theme() .'/front-page.css';
$path_style = path_to_theme() .'/path-'. arg(0) .'.css';
if (file_exists($front_style) && $variables['is_front']) {
$include_style = $front_style;
}
elseif (file_exists($path_style)) {
$include_style = $path_style;
}
if (isset($include_style)) {
drupal_add_css($include_style, 'theme', 'all', FALSE);
$variables['styles'] = drupal_get_css();
}
}
?>BUT... the frontpage and all the admin pages do not read the ie.css file. While in all other pages I can see in the page source the code
<!--[if IE]>
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/mytheme/ie.css?M" />
<![endif]-->
on frontpage and on admin pages it doesn't show up and, of course, IE6 & 7 do not read it. I can bypass the problem by hacking directly the css.files (layout.css ecc) but I would like to find a standard solution which uses ie.css.
Any idea of how I can handle?
Thank you !
Comments
Comment #1
valdes14 commentedFIXED: I'm been suggested to use the body classes and they worked fine handling the problem I had.
For those who run in my same problem I give a little example: let's say we want to modify the background color of the #main div for the home page, we just need to add to our stylesheet.css