Rio Bautista’s TechLog

Tech solutions worth remembering

Reformatting the default CakePHP layout (default.ctp)

So after working on my authentication and application security I thought it’s time to mess with the looks of my site.  To start off, I wanted to obviously change the title of my site and do some minor changes on the main layout.

When you want to change something a programmers first instinct is to look for the text you want to change by maybe doing a grep or a file-search.   And I did, however, the title appeared in a file called default.ctp that was outside my app folder.  And we wouldn’t want to mess with anything outside the app folder specially if it’s inside the cake folder.

After a few more reading, it turns out we need to create our own default.ctp inside our app folder e.g. app/views/layouts/default.ctp.  So what I did was to copy the default.ctp from the cake/libs/views/layout and customized it to my preference.  I realized, the application title, is kinda redundant (as how it was implemented) and I was hoping there’d be some configuration item that I could simply change to globally specify my application title but no.  I’d probably have to do that myself as part of the configuration class.

I’m currently looking for a summary of all the available variables I could put in the default.ctp (of course with some description and explanation as to how to effectively use them)  like I see there’s $title_for_layout, $scripts_for_layout, $content_for_layout,  $cakeDebug.  If I don’t find one, then I’d probably write one if I later find to be important.

January 15, 2008 Posted by Rio | CakePHP, php | | 8 Comments

Syntax highlighting CakePHP using Eclipse

I’m still waiting for an Eclipse plugin for CakePHP so for now I’m settling with the available PHP syntax highlighting on eclipse. So far I had to define two file-types e.g. *.thtml (for 1.1.x.x) and *.ctp (for 1.2.x.x). Do the following steps for each file-type you want to be associated with the PHP-Editor:

  1. Open your Eclipse workspace;
  2. Click on Window | Preferences;
  3. On the Preference Dialog expand the General node on the tree;
  4. Click on Content-Types under General;
  5. On the right panel under Content-Types, expand the Text node;
  6. Select PHP Source under the Text node;
  7. You’ll see the list of files associated on the list below e.g. File-Associations;
  8. Click on the Add button and type the fie extension e.g. *.ctp under file-type;
  9. Click on Ok to add the file-type;
  10. Click on Ok to close the Preference Window;

If there’s a currently opened file (with the extension you added), it will not reflect syntax highlighting until you close and reopen the file. You’re all set!

January 15, 2008 Posted by Rio | CakePHP, php | | 8 Comments