Hi All,

I am not sure if this is really a module or theme question so apologies.

My website uses conditional stylesheets for both ie6 and ie7, and they are currently included in the page.tpl.php as follows:

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

So $styles is output, then all the Javascript, and then these are included if appropriate. I would like to include these in $styles, but still need to output them conditionally.

I tried accessing $styles in a _preprocess_page hook in one of my modules where I set up other variables for page.tpl.php, but by this stage it is already output html.

What is the best way for me to add these to style.css, but still have them output conditionally? do I just add the above string to $styles in the preprocess hook?

Comments

marcvangend’s picture

recommended reading:
http://drupal.org/node/426486

jeebsuk’s picture

Thanks very much, that is an interesting way of doing it that I had not considered. I came up with an alternative solution using the _init hook and using some custom browser detection php, but I will consider your suggestion in future.