Sunday, February 13, 2022

[FIXED] how can i link a bootstrap js file and css file to Cakephp 3x

Issue

im trying to link a bootstrap js file and css file to Cakephp 3x

<?= $this->Html->css('bootstrap') ?> 
<?= $this->Html->css('bootstrap-theme') ?>  

i use this code to src/Template/Layout/default.ctp and the css file is working but when i try to link the js with the same approach

<?= $this->Html->script('jquery') ?> 
<?= $this->Html->script('bootstrap') ?>  

the problem is the Js is not working, thank you for your response


Solution

You can include js like this

  <?= $this->Html->script('https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js') ?>

Or if your js file exist in your project then it must be in webroot/js folder then you can include file like this

 <?= $this->Html->script('custom.js') ?>


Answered By - shubham715

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.