Hi!

I started a new project and I realized that it would be great to have ie conditional classes out of the box.
We could target ie styles without solving this bug http://drupal.org/node/1263750.

<!--[if IEMobile 7]><html class="iem7" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>><![endif]-->
<!--[if lte IE 6]><html class="lt-ie9 lt-ie8 lt-ie7" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>><![endif]-->
<!--[if (IE 7)&(!IEMobile)]><html class="lt-ie9 lt-ie8" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>><![endif]-->
<!--[if IE 8]><html class="lt-ie9" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>><![endif]-->
<!--[if IE 9]><html class="ie9" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>><![endif]-->
<!--[if (gte IE 9)|(gt IEMobile 7)]><!--><html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>><!--<![endif]-->

It works for me :)

Comments

MStrzelecki_’s picture

It works very well with omega's repsonsive logic.

Yuri’s picture

hmm i got this error when using the code above:

Notice: Undefined variable: language in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
Notice: Trying to get property of non-object in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
Notice: Undefined variable: language in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
Notice: Trying to get property of non-object in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
Notice: Undefined variable: rdf in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
Notice: Trying to get property of non-object in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
Notice: Undefined variable: rdf in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
Notice: Trying to get property of non-object in include_once() (line 15 of /home/creative/public_html/sites/all/themes/testsite/template.php).
MStrzelecki_’s picture

You should copy omega's html.tpl.php to your subtheme and replace default html tag with above code.

chaquea’s picture

Thanks miszc, works great for me too and its so much easier to do than loading a bunch of stylesheets

MStrzelecki_’s picture

Omega 3.2?

Yuri’s picture

Yep got it working too. thanks. (3.1 dev version 23 feb)

MStrzelecki_’s picture

Component: Feature Request » Code
cellar door’s picture

Assigned: Unassigned » himerus

Thoughts himerus? IE isn't fun but this could make the lives of those who have to deal that much better

MStrzelecki_’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.54 KB

Status: Reviewed & tested by the community » Needs work

The last submitted patch, omega-ie_conditional_classes_1508452-#9.patch, failed testing.

MStrzelecki_’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, omega-ie_conditional_classes_1508452-#9.patch, failed testing.

MStrzelecki_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.54 KB
MStrzelecki_’s picture

Status: Needs review » Reviewed & tested by the community
TelFiRE’s picture

Great! How soon will this be in the stable release? I'm really needing to target IE and would rather not develop a hacky/custom solution if this is coming very soon. I guess I can patch myself but always like to avoid that stuff :p

Soundvessel’s picture

Can we have the classes setup to have some commonality between IE8 and IE9 as well? I know of at least one CSS issue (transparent gif as background needed to make clear elements clickable) that is shared between IE8 and 9.

squarecandy’s picture

Nice - works for me.

squarecandy’s picture

@telfire - read #3 above - apply this change to html.tpl.php in your subtheme and you won't be hacking the base omega theme.

TelFiRE’s picture

That's ok for now but like I said, I'd prefer it to be in Alpha's because I don't usually use that file and I'd like any updates made there to apply when I update Omega. Not sure if it really matters but not sure why it wouldn't be applied either?

frederico’s picture

I did the same thing squarecandy did and it works great. Thanks to micz_ for this!!! You are a genius!

-Frederico Garza

sutharsan’s picture

I would rather have the functionality of Conditional Stylesheets in Omega instead of this patch. The patch is limited, and always will be, in the browser/versions it supports. Conditional Stylesheets gives you all the flexibility. Zen theme already includes the Conditional Stylesheets code in its base theme. I re-use this part of zen's code everywhere I need it, such as custom themes based on Omega.

fubhy’s picture

We can think about adding that alternative syntax in Omega 4.x .info files and layouts. The syntax that John uses in that module seems reasonable. Alternatively you can still add conditional stylesheets via drupal_add_css() :).

pere orga’s picture

The patch works great for me, thanks!

Does anyone know if it's possible to output the rdf namespaces just once? Now there is a lot of HTML code duplicated.

Unfortunately, the code below does not work:

<html class="<!--[if IEMobile 7]>iem7<![endif]--><!--[if lte IE 6]>lt-ie9 lt-ie8 lt-ie7<![endif]--><!--[if (IE 7)&(!IEMobile)]> lt-ie9 lt-ie8<![endif]--><!--[if IE 8]>lt-ie9<![endif]--><!--[if IE 9]>ie9<![endif]-->" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>>

...

EDIT: Maybe IE does not need RDF?

<!--[if IEMobile 7]><html class="iem7" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"><![endif]-->
<!--[if lte IE 6]><html class="lt-ie9 lt-ie8 lt-ie7" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"><![endif]-->
<!--[if (IE 7)&(!IEMobile)]><html class="lt-ie9 lt-ie8" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"><![endif]-->
<!--[if IE 8]><html class="lt-ie9" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"><![endif]-->
<!--[if IE 9]><html class="ie9" lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"><![endif]-->
<!--[if (gte IE 9)|(gt IEMobile 7)]><!--><html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>><!--<![endif]-->