Installing Prototype/Scriptaculous into your CakePHP App

I wanted to install the prototype framework with the scriptaculous effects to my cakePHP Application, but after uploading the prototype files into the webroot/js folder and linking them in the layout, i got a failure message like “Undefined variable: javascript”.

This variable has to be defined in the Applications Helper, so you can put this line of code in your AppHelper class. If you dont know what to do: create a file named “app_helper.php” in your /app folder and insert these lines of code.

class AppHelper extends Helper {
	var $helpers = array('Html','Javascript','Ajax');
}

The $javascript variable is now available and you can insert your javascript files (the prototype framework in my excample) like this in the head of your layout.

		echo $javascript->link('scriptaculous/lib/prototype');
		echo $javascript->link('scriptaculous/src/scriptaculous');

		// Scripts from a view
		echo $scripts_for_layout;