LoginSignup
0
0

cakephp4 メモ

Last updated at Posted at 2024-07-07
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')) ?>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0