I’m doing practice with CakePHP and just wonder to know if it’s logical/right thing to place CSS portions dedicated to the template view only.
I’m talking about thing like this:
<style>
.form-element-name {
width:150px;
/* colors and other stuff are placed in main css */
}
</style>
<form>
<div class="form-element-name">Username</div><input name="myuser"/>
<div class="form-element-name">Password</div><input name="mypass"/>
<etc.../>
</form>
The cake way of doing this is to do a call to the HTML-Helper like this:
<?php echo $this->Html->css('forms'); ?>The file has to be in the
/app/webroot/cssfolder for this to work. The extension.cssis not needed as the helper adds it automatically.Don’t forget to add the HTML-Helper to your controller
var $helpers = array('Html');If you do it this way you can keep the layout and the content logically separated, which I would call good practice.
Also have a look on the CakeBook for more information about the HTML-Helper.