Reputation: 437
I know that you can use a php file as an external javascript file like below:
<script type="text/javascript" src="myscript.php"></script>
But how would you do this in CakePHP 2.0?
$this->Html->script('external_js', false); automatically adds the .js extension.
This page explains what I want to do: http://nuts-and-bolts-of-cakephp.com/2009/04/03/blend-php-and-javascript-in-cakephp/
but it's out of date. This method doesn't work with CakePHP 1.3+.
Any ideas?
Upvotes: 0
Views: 1079
Reputation: 636
You can get around the automatic addition of the .js extension by adding a question mark at the end of the filename. The Html->script function will add '.js' to any input that does not end in '.js' AND does not contain a '?'.
$this->Html->script('external_js.php?');
Upvotes: 4