javascriptcakephppluginscakephp-3.xcakedc

CakePHP 3 Plugin reference JS in a Template file


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>