Usage
After configuring Jake, all you need to do is to get the appropiate URL so you can host your CakePHP application inside Joomla. In the administrator panel, under the menu Components, select the option Jake, and click on the suboption Get Jake URL for CakePHP action. As a result, you should see a form similar to the following image:
On the select box choose your CakePHP application (taken from the configuration file), and optionally set up a particular controller/action you want to run (if not the default). You’ll get the URL you need to use to run the specified application using Jake. Jake uses its own URL to integrate your CakePHP applications. It will automatically change URLs generated by CakePHP so that the application, once it is running on Jake, stays on Jake.
Let’s see how the CakePHP application Cheesecake Photoblog looks on Joomla 1.5:
Jake Callables
Your CakePHP application can check whenever it is being run on Jake. This gives you the possibility to have a different layout for your application, or do whatever needs to be done differently. When a CakePHP application is running on Jake, a define named JAKE is created, which lets you easily check if you are running on Jake:
Let’s do an example. Our CakePHP application will be run through Jake, but also directly. Furthermore, we want to display the application using a different layout when it is being run on Jake. To do so, create the file app/app_controller.php in your CakePHP application main directory (if you already have one just add the code to your version), with the following contents:
function beforeRender() {
if (defined('JAKE') && (!isset($this->layout) || $this->layout == 'default')) {
$this->layout = 'jake';
}
}
}
You can now create the layout file jake.ctp (CakePHP 1.2) or jake.thtml (CakePHP 1.1) on app/views/layouts, and customize it to suit your needs.
Jake also provides you of callbacks, which lets you take advantage of your bridge to Joomla. To use a callback you will first need to get an instance to Jake object, like so:
You can then use the available callbacks Jake provides. So far these are the callbacks available (more will come):
- getUrl($action, $application): gets the Jake url to run a specific action in a CakePHP application. If the $application parameter is not set, current CakePHP application will be used. Otherwise it will correspond to the application identifier you’ve set on the configuration file. Example:
getUrl('/posts/view/4'). Note that you don’t have to change your CakePHP application links using this callable, since when Jake is running, they will be automatically changed.
Documentation
Navigate
Categories
Can't Miss
- SYPAD Developers CommunityQuality articles, tutorials and projects for developers.
- SYPAD Outsourcing MarketplaceGet your project done, or bid on projects.