php - Cakephp, dynamically write variables into css file upon load of view? -


I am running a process to save actions from jquery in my viewpoint in KCPP .. I have an easy way To load saved values ​​such as width and height for a DIV, KCPP must resize a variable in the CSS file as its width / height, in the same way it will be in the view file .. I suppose I'm not sure about this Where to find information about this, if I think in the cakebook's cookbook that I am missing it because I do not think how to do it .. Any advice is appreciated.

This is really very easy (and powerful), and can be done without the help of KPPHP .

P> First of all, make a new file named css.php in your webroot. The following is placed at the top of the file:

   

Now, the link to this file at the top of your layout, as you will file the normal CSS.

  & lt; Link rel = "stylesheet" Href = "/ path / css.php" type = "text / css" />  

And there you have a dynamic CSS file. You can give it information like this:

  & lt; Link rel = "stylesheet" href = "/ path / css.php? C = red and fw = 700" type = "text / css" /> CLARIFICATION:  To use the above mentioned variable, you will use the  $ _ GET  variable in the CSS file. Take a look at the link tag above in order to access those variables in the CSS file, you will do something like this: 

  .class {color:  After looking at the link posted about CakePHP HTML Helper, I realized that if there is a better way of doing this Intended to pass too many variables in the CSS file. 

Create a new model and controller named Dynamic Style and Dynamic Style Controller (or something like that). Then, create a new layout file called css.ctp, all the views of this controller will be used. Announce the content-type header statement in that layout file.

The final step will be linked to one method in that controller from the head of your controller layout.

Now you can create a database table of CSS rules and you can use it in HTML viewer with CSS viewer.


Comments