Here is peace of code that can allow you to link CSS per controller action, just place the code in to the layout head section /app/views/layouts/default.ctp:

// view specific CSS - css/<controllername>/<action>.css or /css/pahes/<static_page>.css linking, if CSS file exists
$action = $this->params["controller"] != 'pages' ? $this->params["action"] : $this->params["pass"]['0'];
if (is_file(APP.WEBROOT_DIR.DS."css".DS.$this->params["controller"].DS.$action.".css")) {
	   echo $html->css($this->params["controller"]."/".$action);
}

 

Posted by Rostislav Palivoda, filed under PHP. Date: April 18, 2008, 10:21 am |

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.