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.
Rick O (20/11/2008 - 04:35)
Hi James!
I use Dreamweaver CS3 on Mac and I followed your directions exactly. Color codings work as well as the Properties bar. However I cannot switch to Design View as it is disabled, any thoughts?
James (20/11/2008 - 04:57)
@Rick: Thanks for commenting, I'm not sure about the Design View issue your having I've never experienced it myself and unfortunately don't own a Mac to test. Let me know if you solve it tho.
Awbrys (26/11/2008 - 23:27)
To get a .ctp file to open in both 'Code View' and 'Design View' in Dreamweaver, follow the above instructions, but make sure that under your DW "Edit->Preferences->File Types" you do *not* have .ctp listed to "Open in code view" as this will disable viewing in Design View. Took me a while to figure that one out.
Nicholas Z (04/01/2009 - 12:58)
This knowledge base article from Adobe also tells you how to get syntax colored highlighting as well.
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16410
To summarize that article, you need to add the .ctp extension to the MMDocumentTypes.xml file.
Here are the full steps:
Page 3 of 5
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16410
Steps to add extensions to a document type definition in the MMDocumentTypes.xml file:
1. Locate the MMDocumentTypes.xml file in the main Dreamweaver configuration folder (not the Dreamweaver user
configuration folder). The location of this folder depends on the operating system and the version of Dreamweaver:
Dreamweaver CS3 on Windows Vista & XP:
C:\Program Files\Adobe\Adobe Dreamweaver CS3\Configuration\DocumentTypes
Dreamweaver 8 on Windows Vista, XP & 2000:
C:\Program Files\Macromedia\Dreamweaver 8\Configuration\DocumentTypes
Dreamweaver CS3 on Mac OS X:
Mac HD:Applications:Adobe Dreamweaver CS3:Configuration:Document Types
Dreamweaver 8 on Mac OS X:
Mac HD:Applications:Macromedia Dreamweaver 8:Configuration:Document Types
2. Open MMDocumentTypes.xml in any external text editor like Notepad or Text Editor. Do not modify the
Dreamweaver configuration files in Dreamweaver itself.
3. Find the tag set for the desired document type. Below is the default document type definition for HTML documents
from the MMDocumentTypes.xml file:
<documenttype id="HTML" internaltype="HTML"
winfileextension="html,htm,shtml,shtm,stm,tpl,lasso,xhtml"
macfileextension="html,htm,shtml,shtm,tpl,lasso,xhtml,ssi" file="Default.html"
12/20/08 4:07 PM
Changing and adding file extensions recognized by Dreamweaver
macfileextension="html,htm,shtml,shtm,tpl,lasso,xhtml,ssi" file="Default.html"
writebyteordermark="false">
4. Add the desired extension to the winfileextension and macfileextension attributes of the
documenttype tag. For example:
winfileextension="html,htm,shtml,shtm,stm,tpl,lasso,xhtml,inc"
The code above adds the INC file extension to the list of files that Dreamweaver treats as HTML files. Adding
extensions to the Mac OS and Windows lists for this file types allows Dreamweaver to open this file type in Design
view as other files with defined HTML file extensions.
5. Save MMDocumentTypes.xml and restart Dreamweaver.
6. To see the changes, open Dreamweaver and open a file that has the newly added file extension. You should see
that Design view, code coloring and server behavior functionality (if applicable) are working now.
James (06/01/2009 - 10:48)
@Nicholas: thanks for commenting and sharing what you've found. I'm sure it will help a few people out.
archana (20/01/2009 - 02:15)
thanks a lot. wonderfull topic written by you. your topic helped me a lot to solve my problem of not opening .ctp and .html files by dreamweaver. i followed istructions given by you and my problem solved. thanks a loyt again.
Kyle (28/01/2009 - 09:23)
Thanks man!
Jacob (06/02/2009 - 13:26)
Works great with CS4. Thanks a bunch!!!!
Suman (23/02/2009 - 08:18)
Thanks a lot.
Saurabh Goyal (26/02/2009 - 21:28)
Hi All,
Copy of Modifying the Necessary Dreamweaver files also found in C:\Documents and Settings\\Application Data\Macromedia\Dreamweaver 8\Configuration . So,Make sure u also changes below files in this folder also:-
1) Extensions.txt
2) DocumentTypes\MMDocumentTypes.xml
Regards
Saurabh Goyal
Richard C (12/04/2009 - 03:14)
Well, ive given up on Dreamweaver CS3. Ive changed every "Extensions.txt", both the one in applications and the one in library, plus the "MMDocumentTypes.xml" and Dreamweaver will still not open the ctp document, if i create one and assign the .ctp inside dreamweaver then it is assigned as a RTF document.
The steps in Eclipse and im back to work. I wish i knew why i was trying to get it to work with adobe with eclipse installed.
For Eclipse: http://cakebaker.42dh.com/2006/12/26/syntaxhighlighting-for-ctp-files-in-eclipse/
One mentioned is you must close the document once you have made the changed then reopen it and the new color coding will apply.
I Wayan Saryada (29/06/2009 - 08:25)
Hi, thanks for the article. Its really helps me configuring Dreamweaver for editing my CakePHP template files.
jerome (13/07/2009 - 01:16)
Hai James,
Thanks a lot...It works .....I'm using macromedia dreamweaver 8.Thanks a lot man...
Jushadi Arman Saz (21/08/2009 - 05:46)
Hi, James!
Nice tutorial, now I can use DW for editing the code with helpful color, its really help me to make my cake. Keep on your good work
Prof. No Time (08/09/2009 - 05:57)
This worked immediately like magick!!! lol
For users of dreamweaver 8 like myself, the last file is found in YOUR_DOCUMENTS/Application Data/Macromedia/Dreamweaver 8/Configuration/. Thanks man!
alexku (10/09/2009 - 01:39)
The method worked for me only on local files.
But I don't get code colouring when trying to edit remote files on ftp server.
Thank You for any hints in advance :)
mrtobo (25/09/2009 - 12:03)
THANK YOU!
Shannon (03/11/2009 - 05:43)
Thank you for the information.
I tried it out and it did not work the first time, because I have no write privileges in my "Vista" Program Files, folder. If you follow the steps given above and it also does not work for you, then simply copy the <em>Extensions.txt</em> and the <em>MMDocumentTypes.xml</em> files to your desktop, edit them there, and replace(paste) the files back to their original folder.
Raony (15/12/2009 - 02:07)
For people using dreamweaver and crossover you also have to edit the file located in /home/USER/.cxoffice/winxp/drive_c/windows/profiles/crossover/Application Data/Macromedia/Dreamweaver 8/Configuration/Extensions.txt
Have fun :)
Marksten (28/01/2010 - 13:47)
Thank you for this very handy article! Worked right away!
Mescalito2 (17/03/2010 - 14:49)
I used this post in 2008 and then I forgot about it until I got my new laptop (no dreamweaver on it), but lucky me I bookmarked this webpage and here I am again! thanks twice!
Soren (22/03/2010 - 20:31)
Worked like a charm, thank you ;)
marigwil (05/05/2010 - 04:49)
GREAT POST, very usefull, thanks.
works fine.
Ravi (05/05/2010 - 07:08)
If you are using cakePHP you will find files .thtml and .ctp and to open files with extension .thtml and .ctp in Adobe Dreamweaver you need to follow these steps:
1. Open MMDocumentTypes.xml file inside folder (C:\Program Files\ your-dreamweaver-folder \Configuration\DocumentTypes)
2. In line 67 which has id, PHP_MySQL add thtml/ctp extension on, winfileextension=”php,php3,php4,thtml,ctp” macfileextension=”php,php3,php4,thtml,ctp”
3. Open file Extensions.txt inside folder (C:\Program Files\ your-dreamweaver-folder \Configuration)
4. Add THTML,CTP at the first line seperated by comma at the very end so the command will look like ,THTML,CTP:All Documents
5. Similarly add these two extensions to the “:PHP Files” line. so the command will look like, PHP,PHP3,PHP4,PHP5,TPL,THTML,CTP:PHP Files
Now the final step
6. Open file Extensions.txt inside folder (C:\Documents and Settings\Admin\Application Data\ your-dreamweaver-folder \Configuration)
7. Add THTML,CTP at the first line seperated by comma at the very end so the command will look like ,THTML,CTP:All Documents
8. Similarly add these two extensions to the “:PHP Files” line. so the command will look like, PHP,PHP3,PHP4,PHP5,TPL,THTML,CTP:PHP Files
9. Finally, restart your dreamweaver and you should be able to run the files.
rajesh (05/05/2010 - 23:56)
wow its working properly.........
thanks
plumpNation (15/05/2010 - 07:37)
This was superb, not sure if CS5 is mentioned here but the only difference I found was that I didn't have to look for the other Extensions.txt file in my documents as it wasn't there. Instructions worked perfectly though so didn't need to.
A 'spot on' guide you wrote here buddy! :)
Frank (27/05/2010 - 07:07)
Hi, in my MMDocumentTypes.xml file there is no winfileextension in there. I'm using Dreamweaver CS3. What do I have to do?
Thx,
Frank
James (28/05/2010 - 04:36)
@Frank: hmm not sure, does changing the other stuff not do it?
Frank (31/05/2010 - 04:25)
Hi James, thx for reply. The changes done in the Extensions.txt did not bring Dreamweaver to color-code .ctp yet. Seems there is a change in handling this in CS3. :-/
Chris Riley (11/06/2010 - 03:37)
Many thanks, saved me hours. Good stuff
magori (15/07/2010 - 10:02)
thanks
tacoboy (21/07/2010 - 02:26)
Doesn't work on Win7 + Ultimate Dreamweaver CS5.
brad (08/08/2010 - 13:09)
for cs5 and windows 7 you need to edit one more configuration file:
C:\Users\username\AppData\Roaming\Adobe\Dreamweaver CS5\en_US\Configuration\extensions.txt
edit just like the other extension files