Opening CakePHP Files in Dreamweaver
I primarily use Adobe Dreamweaver to create and code all of my websites, mainly because of the code highlighting and the way I organise my sites in separate folders. I realise that there are loads of text editors out there but Dreamweaver is what I’m comfortable with and it does the job.
When starting out with CakePHP I quickly found out that Dreamweaver doesn’t open .THTML and .CTP files automatically and I had to do a bit of hunting on the web to get the problem solved. The solution is pretty easy so this is just a quick post to get Dreamweaver opening .THTML and .CTP files.
THTML and CTP Files
Although I’m using CakePHP 1.1 which uses .THTML files I’ll also add the latest .CTP files which CakePHP 1.2 use. This is just saving time and when I do cross over and start using version 1.2 I don’t have to fiddle around with Dreamweaver again.
Modifying the Necessary Dreamweaver files
There are ultimately 3 files that you need to edit. The first two are located in the folder that you installed Dreamweaver, in my case this is “C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration” although I’m using the latest version of Dreamweaver previous versions also have a “configuration” folder so go there.
Open up “Extensions.txt” and on the first line at the very end add THTML and CTP separated by commas, so the line should read:
,MASTER,THTML,CTP:All Documents
Similarly add these two extensions to the “:PHP Files” line.
PHP,PHP3,PHP4,PHP5,TPL,THTML,CTP:PHP Files
Next open the “DocumentTypes” folder and edit the “MMDocumentTypes.xml” file, just open it up using notepad or wordpad. Search for the line which has an id “PHP_MySQL” and add the THTML/CTP file extensions to both the “winfileextension” and “macfileextension” so the line should read:
winfileextension="php,php3,php4,php5,thtml,ctp" macfileextension="php,php3,php4,php5,thtml,ctp"
The final file is another version of the “Extensions.txt” which is located in your “Documents and Settings” Folder in my case this is “C:\Documents and Settings\James\Application Data\Adobe\Dreamweaver 9\Configuration” just add the very same things you inserted earlier.
Wrapping Up
Restart Dreamweaver and you should now be able to open up and edit .THTML and .CTP files with everything nicely colour coded. A short post but a needed one for those who use Dreamweaver.
Comments
Vivien Markey (29/02/2008 - 03:34)
Hi, i have followed your instructions and now when i open Dreamweaver it pops up with a message saying "The document type "PHP" will not be added because it uses a file extension that is already associated with a prior document type". Is this normal. Do you know why this is happening. I suspect that i may have changed the wrong line in the document types file and i no longer have the original version so i cannot revert to that. Please could you send me the contents of the documents types file so that i can correct this error. Hope you can help. Viv
James (02/03/2008 - 08:30)
Hey,
Sorry for my late reply just came back from holiday, not sure why your encountering that problem i've never had that error message before. Let me know if your still having problems and i'll send you the files that I use to see if it fixes things.
James
Fahad (05/03/2008 - 06:35)
thanks! it worked!
Herod (07/03/2008 - 06:29)
Vivien, this is because you write two extensions per line.
If you check again and delete duplicates it will work.
;)
BlitzkriegFC (19/03/2008 - 22:43)
Thanks a lot, it worked for me. I'm starting on CakeWorld and this will help me a lot. Greetings
Mike B (02/04/2008 - 11:27)
works great, definitely help when editing those files in dreamweaver.
Pozowebs (06/04/2008 - 12:57)
Thanks it worked! It's so easy but still I had no clue on how to do it. I googled "how to use dreamweaver ctp" and I found your article. Thanks!
Vivien Markey (12/04/2008 - 08:27)
Hi, thanks for the help. I have sorted it out now. Well i did sort it out soon after my first post but only just reading the replies :-)
Richard (23/04/2008 - 10:48)
Hello, I was wondering how you get the graphics from the cakePHP files to show in DW. A friend did our site using cakephp and I am trying to view the pages in DW to edit. I need to see the graphics but I cannot get the graphics to show.
James (24/04/2008 - 04:46)
Hi Richard,
This is happening because you are trying to view the files using Dreamweaver's Design view, unfortunately because CakePHP runs on PHP the code needs to be executed by a server and that's why the images wont display.
A solution would be to run a local server to see your changes or make your site live, other than that not too sure what you could do.
James
Doug (29/04/2008 - 08:56)
I also had to edit the XML file in the Documents and Settings folder. Not sure if I mis-read what you posted or if I did something else previously to cause that further edit. Thanks for the info.
keith (10/06/2008 - 21:01)
"The document type "PHP" will not be added because it uses a file extension that is already associated with a prior document type" - it means that you added the extension when it's already there.
MRK (14/06/2008 - 00:36)
Thanks, it's working well now. What about searching option in .ctp file... It is not searching in .ctp file when we select folder search... Do you have any solution like this....
Matt (19/06/2008 - 23:23)
Thanks James. Very well documented.
I worked this out a year or two back, and then recently reinstalled my laptop. I should have documented it via blog like yourself. :-)
Thanks again.
David Tierney (22/06/2008 - 12:31)
I wish I could say it worked for me, but it did not. I don't know if it was because I had Dreamweaver opened when I made the changes. I am using DW CS3, on a Mac (maybe that is the difference?), and restarted first DW, then my computer to see if that would help. No luck.
David
David Tierney (22/06/2008 - 12:40)
Follow up. I realized that in your final step above, I had changed the extensions file for an earlier version of Dreamweaver 8. When changed it for 9, all worked. Thanks for sharing this.
James (23/06/2008 - 10:33)
@David Tierney, no probs David. I've never tried it on a Mac but I wouldn't think the process would be different. Glad it helped.
Shamus (21/07/2008 - 05:05)
MRK's comment seems to have gone unnoticed. .ctp files are not able to be searched from within Dreamweaver and this seriously hampers skimming swiftly through the code base; especially one you are taking over from another developer. Will update here if I find any way to do this.
Shamus (21/07/2008 - 06:08)
As promised, here is .ctp files become searchable in Adobe Dreamweaver CS3! Edit the appropriate line in C:\Documents and Settings\(USERHERE)\Application Data\Adobe\Dreamweaver 9\Configuration\Extensions.txt so that it looks like this:
PHP,PHP3,PHP4,PHP5,TPL,THTML,CTP:PHP Files
Exit and relaunch Adobe Dreamweaver CS3 and, hey, presto! Your search results will now include .ctp file contents.
James (22/07/2008 - 04:58)
@Shamus: Thanks for that, MRK's comment did indeed pass me by. Glad you could find a solution.
ashorlivs (27/07/2008 - 07:19)
If you're happily using a Mac, changing the default configuration file will probably be useless.
In my case, I had to edit the files located in ~your_user_folder/Library/Application Support/Adobe/Dreamweaver 9/Configuration
Madras (01/09/2008 - 08:46)
GREAT! Exactly what i was looking for - thank you for investing your time in this. You rock!
Nicolas (23/09/2008 - 19:13)
Thanks dude!
Aldwin (25/09/2008 - 03:29)
Hi All,
I have followed the instruction and still dreamweaver editor doesn't recognize the .ctp extension.
Anyone have an idea what causes the problem.
Thanks in advance!
Aldwin
James (26/09/2008 - 04:47)
@Aldwin: Hmm not too sure why its not working, that's usually all I have to do to get it working. Double check everything.
Awais (08/10/2008 - 05:12)
hi i followed ur steps it recognized the ctp extensions and also show color codings for html code but dont show any color code for php code.
Karl-Johan (08/10/2008 - 07:57)
Thanks!
After spending an frustrated hour reading Dreamweaver help, this worked at once.
Karl-Johan
Journey (08/10/2008 - 13:04)
Thanks, it works fine!!
James (09/10/2008 - 04:54)
@Awais: Make sure you've added "thtml,ctp" to the "PHP files" line - that should fix your problem.
@Karl-Johan, Journey: Thanks for commenting and glad it worked.