0

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?

1 Answer 1

4

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?'); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.