How to add a css to a view in the Controler?

Tags: css,cakephp,cakephp-2.0

Problem :

I'm working with cakephp 2.0 and would like to use different css for each views.

Do you know the way of changing the result of the command $this->fetch('css') in the default.ctp template?

  var_dump ($this->fetch('css')) ; 


string(0) "" 

I found in the cookbook but this is of no interest, since the < link rel="stylesheet" type="text/css" href="/css/forms.css" / > tag is only located in the < header > section and that my view templates does not have the < header > section in it.

An other kind of answers is to use an array as view parameter and to change consequently the default.ctp which parse this css files array. But is this kind of helper already included in the base cakephp2.0?

Thank for any answer.

Solution :

Simply use HtmlHelper::css() in the views to add CSS files as you need. Use inline => true to make it inline if you do not want to have it in the header.

    CSS Howto..

    How to add a box shadow to a table tr element upon hover? [duplicate]

    how to make the img at the left side and the texts at the right side vertically line up

    How to displaying and hiding again the div after clicking a button

    How to apply CSS to elements that have multiple classes?

    Push vertically resizable Div to bottom of wrapper. How?

    How to link after the CSS-Animation?

    How to prevent a div from disappearing when you hover a link in pure css

    How to trigger CSS-Filter animation on Click (or Scrolling)

    how to add a css style property dynamically in JSF

    yui-css grid: how to get a 1/4 - 2/4 - 1/4 grid set up?

    How to make bootstrap 3 navbar not wrap

    How to let the chrome forget the page scroll position?

    How to capitalize first letter with JSTL/CSS?

    How to make all input boxes ordered in a straight line? [closed]

    How can I erase a border piece using CSS?

    How do you modify wordpress css for posts?

    How to draw a gradient colored trapezoid with css3?

    How to capitalize first line with css? ::first-line psuedo-element CSS not working

    How to increase the height of footerrow in jqgrid

    CSS, HTML issue. How would I get the main body of the document to be a certain way down from the top?

    CSS: How to move hint box (a:hover) to the left?

    How to prevent an empty img element from shrinkage?

    DOM How to add two divs (with jQuery inside them) next to each other?

    How to align an element applying css margins that does not get modified according to browsers and screen resolutions?

    How does one create a div that extends to the bottom of the page?

    How to fix crispy text in Safari 5 Mac OS X after using css 3d transforms?

    How to give a javascript function and css style in struts2 property tag

    How to style the NSString using CSS?

    How can I make a div 100% of the browser window height, but with a top and bottom margin?

    How can I get the current state of my div animation?