Documentation > Usage

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:


Click image to enlarge

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:


Click image to enlarge

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:

if (defined('DRAKE')) {
        // We are on Drake
}

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:

class AppController extends Controller {
        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:

$drake =& Drake::getInstance();

You can then use the available callbacks. So far these are the available callbacks:

Documentation


Navigate

 

Categories


Can't Miss