I've created a custom bartik subtheme in D7, but I can't figure out how to call my own ie stylesheets from my subtheme's css folder. The ie stylesheets are called from bartik's css folder. I tried installing the Conditional Stylesheets module, but it doesn't seem to work with a subtheme. Can anyone help?

Comments

devtherock’s picture

Have you tried this in .info file ?

conditional-stylesheets[if IE][all][] = ie.css
traceelements’s picture

Thanks, yes, I did try that, and I guess it doesn't work with a subtheme?

devtherock’s picture

I guess only zen theme have ability to put conditional stylesheet in its subtheme.
for others you can check out this module http://drupal.org/project/conditional_styles

traceelements’s picture

That's the module that I tried, but thanks for trying to help...

traceelements’s picture

I figured out how to do it. For anyone else who is wondering, this is what I did.

I created a blank template.php file and put it in my subtheme folder.

Then I added this code to the file:

<?php

function bartik_preprocess_html(&$variables) {
  // Add conditional stylesheets for IE
  drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
  drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
}

with the word "bartik" replaced with my subtheme name.

themusician’s picture

I too had difficulty getting the sub-theme to recognize the IE conditional comments. I did as traceelements did above and now have it working. My subtheme already had a template.php file in it so I just modified mine. Also, pay attention to the number of styles being loaded, and try turning on CSS aggregation to ensure your conditional comments will load properly. I had to clear the cache often to ensure that the styles were loaded properly.

I got the conditional styles module to work properly as well but thought it superfluous to the drupal_add_css() hook.

Kristina2012’s picture

I was just looking for this issue and it saved my day thanks a bunch !

http://www.cuckolding.se