adapt css,javascript in cakephp

Asked 2 years ago, Updated 2 years ago, 54 views

app/MySample/index.ctp
What would be the best way to adapt css to the above file?
Should I create a css folder in app/MySample, put the css file in it, and say echo$this->Html->css('sample'); in the controller?
Similarly, I would like to know how to adapt JS.
Please let me know if you know more.

javascript php css cakephp

2022-09-30 18:30

1 Answers

In CakePHP, public files (such as css, javascript, and images) are located in APP/webroot/.

If it is css, place it under APP/webroot/css/.

For example,

echo$this->Html->css('sample');

reads APP/webroot/css/sample.css.

HtmlHelper::css()Read the following documentation first to learn about the behavior and options of the method.

HtmlHelper —CakePHP Cookbook 2.x Documentation
http://book.cakephp.org/2.0/ja/core-libraries/helpers/html.html#HtmlHelper::css

You can also load JavaScript files using HtmlHelper::script().
The JavaScript file is located in APP/webroot/js/.

Please refer to the manual for instructions.

HtmlHelper —CakePHP Cookbook 2.x Documentation
http://book.cakephp.org/2.0/ja/core-libraries/helpers/html.html#HtmlHelper::script


2022-09-30 18:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.