Search

How can I use the if IE tag inside the XSLT douments?
For example the code below:

<!--[if IE 7]>
    <link rel="stylesheet" href="css/ie7.css" media="screen" />
<![endif]-->

This should do it:

<xsl:comment><![CDATA[[if IE 7]>
<link rel="stylesheet" href="css/ie7.css" media="screen" />
<![endif]]]>
</xsl:comment>

Or if you need to use variables or other XSL elements within the comment, you can use the following:

<xsl:comment><![CDATA[[if lt IE 8]>&lt;script type="text/javascript" src="]]><xsl:value-of select="php:function('mtime', 'layout/js/funny-old-ie.js')"/><![CDATA[">&lt;/script><![endif]]]></xsl:comment>

There’s an XSLT Utility for conditional comments…

It goves you the option to specify the IE version, and advises the above also.

I tried the code from mqchen and it doesn’t work properly.
This is the code from the output:

<!--
            [if IE 7]>
                <link rel="stylesheet" href="css/ie7.css" media="screen" />
            <![endif]
        -->

Sorry about that. The indents were wrong. Try something like this (ie. no whitespace after the opening comment tag and none before the closing one:

<xsl:comment><![CDATA[[if IE]>
<link rel="stylesheet" type="text/css" href="{$workspace}/css/ie.css" media="all" />
<![endif]]]></xsl:comment>

Alright that was the issue, thanks.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details