1 css読み込み----------------------------------------------------
C:\php-dev\cakephp\TestPro\webroot\css\admin\bootstrap.css
C:\php-dev\cakephp\TestPro\templates\Admin\index.php
場所:先頭
<?php
echo $this->Html->css("admin/bootstrap.css");
?>
2 javascript読み込み---------------------------------------------
C:\php-dev\cakephp\CiNet\webroot\js\admin\bootstrap.min.js
C:\php-dev\cakephp\TestPro\templates\Admin\index.php
場所:先頭
<?php
echo $this->Html->script("admin/bootstrap.min.js");
?>
3 CakePHPでjavaScriptとCSSファイルを指定した位置で読み込むようにする
以下のように記述すると、それを記述した位置でそのまま読み込まれてしまうため、思い通りの動きにならないことがあります。
<?= $this->Html->script('mdl-selectfield.min.js') ?>
<?= $this->Html->css('mdl-selectfield.min.css') ?>
そこで出力したい位置に以下のような指定をしておくことで、その場所に出力させることができます。
例:出力したい位置
<?= $this->fetch('head') ?>
例:出力させたい内容
<?= $this->Html->script('mdl-selectfield.min.js', array('inline' => false, 'block' => 'head')) ?>
<?= $this->Html->css('mdl-selectfield.min.css', array('inline' => false, 'block' => 'head')) ?>
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme