Appending Conditional Stylesheet / CSS on Zend Framework

Because of some browser incompatibility, you need to have some piece of CSS on your page for a specific browser, ex: IE.

If you are using Zend Framework, it would be easy. In the controller, you can include the stylesheet / CSS using this:

$this->view->headLink()->appendStylesheet(PUBLIC_WEB_PATH . '/css/account_form_ie.css', 'all', 'IE');

The headLink() helper has the method:

appendStylesheet($href, $media, $conditionalStylesheet)

If you simply want to include a CSS file, you may ommit the media and conditionalStylesheet parameter.

The output would be:

<!--&#91;if IE&#93;>
<link href="/daito/public/css/account_form_ie.css" media="all" rel="stylesheet" type="text/css" />
<!&#91;endif&#93;-->

Source: http://surlandia.com/2008/02/22/conditional-stylesheet-using-headlink-placeholder-zend-framework/

This entry was posted in Web Development, Zend Framework and tagged , , , , , , , , , . Bookmark the permalink.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *