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

Friday, March 11, 2022

[FIXED] CakePHP 3 Plugin reference JS in a Template file

 March 11, 2022     cakedc, cakephp, cakephp-3.x, javascript, plugins     No comments   

Issue

I have my register.ctp Template file in my Users plugin that I want to reference a js file that is also within my plugin

vendor/cakedc/users/webroot/js/password-compare.js

How do I reference this js file in my Template file?

I've tried

<?= $this->Html->script("password-compare"); ?>
<?= $this->Html->script("Users.password-compare"); ?>
<?= $this->Html->script("/Users/webroot/js/password-compare"); ?>

and then

<?= $this->fetch('script') ?>

But nothing has worked so far... any hints?


Solution

I've ended up just adding the following code, works fine but not as elegant as I might of liked...

<script src="<?= $this->request->webroot ?>/cake_d_c/users/js/password-compare.js"></script>


Answered By - Sanfly
  • 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