Specify Stylesheets for Different Media Types with $html helper

I’m expanding my CakePHP experience and now I’ve delved into displaying the application on multiple devices and of course, print.

Print stylesheets can be tricky to design, but it took me a while to figure out how to have cake automatically add them to the template using the $html helper.

	//you specify the file name first, then the media types at the end.
	echo $html->css('simple', null, array('media'=>'print'));
	echo $html->css('regular', null, array('media'=>'screen')); 
	echo $html->css('simple', null, array('media'=>'print')); 

This will output something like this:

<link rel="stylesheet" type="text/css" href="/css/simple.css" media="print" />
Be Sociable, Share!