PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 24, 2022

[FIXED] CakePHP - Web page try to load all the js files in the webroot

 January 24, 2022     cakephp, javascript     No comments   

Issue

I have a big project using CakePHP. I have a web page and I only want it to load the js files in a subfolder of webroot but it seems like loading all the js files in the webroot

I want files in this directory

/webroot/js/signaturepad

and in my code I wrote:

echo $this->Html->script(array(
                '/js/signaturepad/TopazSignature',
                '/js/signaturepad/SigWebTablet'
            ), array('inline' => false));

So it supposes to read these two js files only while in the page source I can see tons of js files in the webroot been loaded. And my js functions are not working at all.


Solution

I want files in this directory

/webroot/js/signaturepad

start paths without slash '/' and 'js' folder name, like:

echo $this->Html->script(array(
         'subfolder/your_js_file_name_here',
         'subfolder/your_js_file_name_here.min'
     ), array('inline' => false));

This generate path like example.com/js/subfolder/your_js_file_name_here.js

If you want use other folder inside webroot folder, for example: 'frontend' then start path with slash '/'.

echo $this->Html->script(array(
         '/frontend/your_js_file_name_here',
         '/forntend/your_js_file_name_here.min'
     ), array('inline' => false));

This generate path like example.com/frontend/your_js_file_name_here.js



Answered By - Salines
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing