browser specific registerCSSFile

My problem is that I want to register a CSS file using clientScript->registerCssFile().

But I want to embed it within <!–[if gte IE 6]>



Is this possible?

There is no direct way to do this in Yii. A workaround is to simulate the way how CController::pageTitle is being used. Basically you can define a property in the base controller class. You then store IE6 js in this property and echo it in the layout view.

tombrown, this is how I used a browser specific CSS file in a view

<?php echo CHtml::cssFile(Yii::app()->baseUrl.'/css/screen.css', 'screen, projection'); echo "n"; ?>

<?php echo CHtml::cssFile(Yii::app()->baseUrl.'/css/print.css', 'print'); echo "n"; ?>

<?php echo '<!--[if IE]>'.CHtml::cssFile(Yii::app()->baseUrl.'/css/ie.css', 'screen, projection').'<![endif]-->'; echo "n"; ?>

Hope this helps a bit

We have extended CClientScript to add a new position type POS_IE6 and handle the output of scripts added with this position in a different way.

However, it was made more complicated by the fact that several variables we needed access to are private in the baseclass (CClientScript).  For example, the $_scripts array.

In an extensible, flexible framework, I would say class variables should only be public or protected.  This way you don’t need to pre-empt how someone might want to extend a class. There’s rarely justification for making them private…  IMHO.

Any comments Qiang?

I just exposed the clients property to be protected.

The general rule regarding these member variables is that we will always start with private. And if there is any need to access a member variable, we will evaluate and turn it into protected. By doing so, we reduce the possibility of breaking BC between versions.