Usage
Once you have properly installed and configured Drake on your host, you can now get the Drake URL that is necessary to execute your CakePHP application in Drupal. To do so, log in as administrator on your Drupal website, click on Administer -> Site Building -> Drake. You should see Drake’s documentation now. Next, click on the tab named Get Drake URL and you should get something like this:
On the list box select your CakePHP application (you can notice that they are the ones defined on the configuration file), and set up a particular controller/action you want to run (leave empty to use your application’s default action). After clicking on the button Get Drake URL, you’ll be given the URL needed to run the specified application in Drupal using Drake. Drake will automatically change all URLs generated by your CakePHP application so that your application keeps running on Drake.
As an example, take a look at the following screenshot that shows the CakePHP application named Cheesecake Photoblog running on Drupal 5.1:
Drake Callables
On your CakePHP application you may want to do certain things went it is running on Drupal, so you’ll want to check if it is running through Drake (since they can also be executed without Drake.) This gives you possibilities such as use a different layout (so it blends in with your Drupal layout). When a CakePHP application is running on Drake, a PHP define named DRAKE is available, so you can do:
Let’s see an example of this flexibility. We want to display our CakePHP application using a different layout when it is running over Drake. To do so, create the file app/app_controller.php in your CakePHP application main directory with the following contents:
function beforeRender() {
if (defined('DRAKE') && (!isset($this->layout) || $this->layout == 'default')) {
$this->layout = 'drake';
}
}
}
You can now create the layout file drake.ctp (CakePHP 1.2) or drake.thtml (CakePHP 1.1) on app/views/layouts, and customize it to suit your needs.
Drake also provides callbacks that give you different functions to interact with Drake. To use a callback you will first need to get an instance of the Drake class:
You can then use the available callbacks. So far these are the available callbacks:
- getUrl($action, $application): gets the Drake url to run a specific action in a CakePHP application using Drake. If the
$applicationparameter is not set, the current CakePHP application (the application that is currently running) will be used. Otherwise it will use the application identifier you’ve set on the configuration file to identify it. Example:getUrl('/posts/view/4'). Note that you don’t have to change your CakePHP application links using this callable, since when Drake is running, they will be automatically changed for you.
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.