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.
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:
- Open your Eclipse workspace;
- Click on Window | Preferences;
- On the Preference Dialog expand the General node on the tree;
- Click on Content-Types under General;
- On the right panel under Content-Types, expand the Text node;
- Select PHP Source under the Text node;
- You’ll see the list of files associated on the list below e.g. File-Associations;
- Click on the Add button and type the fie extension e.g. *.ctp under file-type;
- Click on Ok to add the file-type;
- 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!
-
Recent
- My Move to the OSX (the dark-side)
- Skype & Apache conflict
- Simple yet effective way to replicate/mirror a database (any database at that)
- MySQL .frm recovery
- cakePHP calls crashing Apache
- Reformatting the default CakePHP layout (default.ctp)
- Syntax highlighting CakePHP using Eclipse
- Intersecting Entities on CakePHP Models
- Integrating Flickr into my PHP web-app
- Installing CakePHP
- Accessing a POP3 mailbox using PHP
-
Links
-
Archives
- October 2009 (2)
- April 2009 (2)
- February 2008 (1)
- January 2008 (6)
-
Categories
-
RSS
Entries RSS
Comments RSS