I know I need to put ie7.css into the basic.info file list of style sheets, but I don't see where the logic is that tells only the IE7 browsers to look at that stylesheet. Thanks.


VM’s picture

zen theme does conditional stylesheets:

in .info file

  ; Set the conditional stylesheets that are processed by IE.
conditional-stylesheets[if IE][all][]       = ie.css
conditional-stylesheets[if lte IE 6][all][] = ie6.css
conditional-stylesheets[if lte IE 5][all][] = ie5.css

That should get you started?

gettysburger’s picture

Thanks so much. I'll give that a try.

gettysburger’s picture

Status: Active » Closed (fixed)

I did some more poking around and found the code in the page.tpl.php file. I added the stylesheets[all][] = css/ie7.css to the basic.info file and viola, I'm in. Lots of thanks to everyone.

grasmash’s picture

Wouldn't that load ie7.css all of the time?

grasmash’s picture

Status: Closed (fixed) » Active

Hm, I don't quite understand. I found this code in page.tpl.php also:

<!--[if IE 7]><style type="text/css" media="all">@import "<?php print $base_path . path_to_theme() ?>/css/ie7.css";</style><![endif]-->

But in IE7, the stylesheet doesn't load. Why is that?

gapa’s picture

For IE6 i had to change line:

<!--[if lte IE 6]><style type="text/css" media="all">@import "<?php print $base_path . path_to_theme() ?>/css/ie6.css"</style><![endif]-->


<!--[if lte IE 6]><link type="text/css" rel="stylesheet" media="all" href="<?php print $base_path . path_to_theme() ?>/css/ie6.css" /><![endif]-->

Try similar for IE7. And please report back how it goes.


SteveK’s picture

hm, maybe M$ depreciated this code? There's also this module: http://drupal.org/project/conditional_styles

EvanDonovan’s picture

Status: Active » Fixed

This still works, afaik - it was working on my version of the Basic theme as of today.

    <!--[if lte IE 6]><style type="text/css" media="all">@import "<?php print $base_path . path_to_theme() ?>/css/ie6.css";</style><![endif]-->
    <!--[if IE 7]><style type="text/css" media="all">@import "<?php print $base_path . path_to_theme() ?>/css/ie7.css";</style><![endif]-->

is in my page.tpl.php. Note that the IE 7 line also gets picked up by IE 8 compatibility view.

Neither line will work if there is not a CSS directory in your copy of the theme, or if it doesn't have these files in it, or if the permissions are set incorrectly on them.

If this still isn't working for you, Conditional Styles (as mentioned in #7) is a good alternative.

Marking as fixed. Reopen if more clarification is needed.

david3000’s picture

Same issue here guys :(

my page.tpl.php is:

   <!--[if lte IE 6]><style type="text/css" media="all">@import "<?php print $base_path . path_to_theme() ?>/css/ie6.css";</style><![endif]-->
    <!--[if IE 7]><style type="text/css" media="all">@import "<?php print $base_path . path_to_theme() ?>/css/ie7.css";</style><![endif]-->

and in my .info file set:

stylesheets[all][] = css/ie7.css

Thanks in advance!!

EvanDonovan’s picture

Status: Fixed » Postponed (maintainer needs more info)

Look at the HTML source of the rendered page, and see if the page in the import statement references a file that actually exists. If it does, then check the file permissions. Otherwise, create the file.

Countzero’s picture

Hi all. I'm starting to love this theme and use it as my work base for several projects. I've been very happy with it so far. Thanks for your work on it.

I run into the same problem as the other people above.

I tried the traditional way (basic as is), directly copying the lines into page.tpl.php and front, checked the permissions and accessed the css in the browser, conditonal-stylesheets (with the relevant module installed and enabled), nothing works. Even pasting conditional comments which I know work on another website of mine doesn't work.

What bugs me is that statements get added to the page source, but don't seem to be recognized by IE. I used IE tester and the computed style doesn't mention the dedicated sheets, nor does they appear in the stylesheets list.

I'm still working on this and will update this thread if I find something but as of now, I don't see anything else to try.

In the meantime, any help would be very appreciated (project launch ahead).

Countzero’s picture

OK, I sort of understood.

It happens I hit the 32 css limit, and got on a false track when reading this bug.

It now works with the conditional style module, so I'll leave it as it is.

You can discard my previous comment. Thanks for reading.

SteveK’s picture

If you hit the limit, you can use CSS aggregation to slim it down. Otherwise, check out the http://drupal.org/project/conditional_styles module.

EvanDonovan’s picture

I believe this functionality made it in to Drupal 7 core, as well, in case that is relevant to you.

Countzero’s picture

Yes that's what I did (aggregation) but it has nothing to do with this issue. Thanks for your replies anyway.

EvanDonovan’s picture

Status: Postponed (maintainer needs more info) » Fixed

Marking as fixed.

grasmash’s picture

Status: Fixed » Needs review

I don't see why this issue has been closed. Drupal 7 core may implement aggregation automatically, but that isn't necessarily the cause of this issue. IE7 fails to see the conditional CSS stylesheets even when aggregation is enabled.

In comment 14, SteveK recommends using an additional module as a work around. That module's documentation suggests using the following code in your page.tpl.php file:

<!--[if lt IE 7]>
  <link type="text/css" rel="stylesheet" media="all" href="ie6-and-below.css" />
<!--[if IE 7]>
  <link type="text/css" rel="stylesheet" media="all" href="ie7.css" />

Which, adapted to the needs of the Basic theme, would look something like this:

<!--[if lt IE 7]>
  <link type="text/css" rel="stylesheet" media="all" href="<?php print $base_path . path_to_theme() ?>/css/ie6.css" />
<!--[if IE 7]>
  <link type="text/css" rel="stylesheet" media="all" href="<?php print $base_path . path_to_theme() ?>/css/ie7.css" />

Maybe that modification will fix it. If anyone could try this out and verify, that would be helpful.

EvanDonovan’s picture

Status: Needs review » Needs work

I marked this as fixed based on Countzero's comment in #13, and since other people had reported that it was working. (I have never had this issue myself.)

I misread which module was recommended, though, in #14. I think that IE Unlimited CSS Loader (which allows you to go above the 32 stylesheet limit in Drupal 6, as well as 7, by using @import statements to load the CSS) would actually fix this.

I think I see your point about the dynamic path, although unless you are using Basic as a base theme, that shouldn't be an issue.

I think that it might be better though, rather than using your code from #18, if the Basic theme was reworked to add the conditional stylesheets to the .info file, as the Conditional Stylesheets module does.

Moved to "needs work", since your code is not a patch.

56rosa’s picture

Hello madmatter23,

I have enabled this conditional_styles module, but in the end, I find it more confusing. I mean that even by clearing the cache in Performance, I can't see any change.

I have:

conditional-stylesheets[if gt IE 6][all][] = css/ie7.css
conditional-stylesheets[if gt IE 7][all][] = css/ie8.css

in the info file. And the page for this module says that it adds automatically the code in page.tpl.php
Well, I don't see it anywhere.

So, I'm thinking of going back to my other solution here: http://drupal.org/node/986318

Except that I cannot somehow attach the css, even if Prajakta's explanation is very good. So, I thought by adding the style css to the info file, it would solve my problem, but then the style for ie8 also shows up in the Firefox browser. So, it's like it's overriding my theme.css then.

So, I dunno right now. I'm getting a bit of a headache trying to make it all work for IE8.
What do you think I should do in the end please?

Thanks a lot

56rosa’s picture


I'm finally seeing my changes: Please see last comment here http://drupal.org/node/986318


damiankloip’s picture

damiankloip’s picture

Status: Needs work » Fixed

This is a cross over of another ie stylesheet related issue which has been resolved and committed. I think it is the conditionals in the page.tpl.php file and the 32 file MS limit. Which there is also a solution for (with ie_css_optimizer and conditional_stylesheets)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.