Dreamweaver Syntax Highlight Tip
I use Dreamwweaver CS3 for all of my code editing, and I currently have the pleasure of working with the new Magento Shopcart Software. While adding Shadowbox to the cart, I ran into the small problem of Magento template files that use the rare .phtml file extension. As Dreamweaver by default does not color code the syntax, it makes it difficult to read the php code that makes up the template file.
Here is how I added syntax highlighting to a specific file type that is not listed by default in Dreamweaver.
First, I noted what language the template file is made up of. Even though the file extension is .phtml, I know that the actual language is php.
Second, I opened the document type config file in the Dreamweaver installation folder. This should be found in this general area.
C:\Program Files\Adobe\Dreamweaver CS3\Configuration\DocumentTypes\MMDocumentTypes.xml
I opened the file with Notepad, and hit Control + F, and entered winfileextension=”php as my search query. This jumped me down to where the list of file types that use a specific syntax highlighting. My list appeared as winfileextension=”php,php3,php4,php5″.
All I did was add a comma and phtml to the end of that list:
winfileextension=”php,php3,php4,php5,phtml”
Then I saved the file and restarted Dreamweaver. Now any file with the .phtml file extension receives the same syntax highlighting as a php document.
Before and After





Thanks Chad! Perfect timing.
Just started a new project at work using the Zend framework and while I could get DW to recognize the extension, syntax highlighting wasn’t working.
Glad to help. You bring up another good trick.
Allowing DW to recognize and edit a specific file type
In DW, go to EDIT > PREFERENCES
At the end of the list of extensions, hit space, and add your new file extension type.
I added these 3: .htaccess .info .htpasswd
Thx Chad,
I was alreday hatin dw for not letting me assign syntax schemes to specific filtypes in the prefs dialog! Wave your mouse in the air and say idahooooooo!
Mortimer
Haha. Thats actually how I start my mornings at work, every day.
I too have problems with the color syntaxing, I tried everything to get the code color enabled. I followed the instructions, but the file won’t allow me to save. Do I have to do it in administrative mode?
Found the problem.
I used PTHML instead of PHTML
Works perfectly now!
Thanks for the write up, this also lead me to change the colour syntax for the ‘null’ attribute. By default dreamweaver only converts the uppercase value to green (Which is annoying seeing the true & false attributes are not case dependant) For those interested heres how to do it.
Open up the file:
C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration\CodeColoring\PHP.xml
Note: I had to copy the file to my desktop, edit then paste back because of Vista’s security…
Anyways… search for ‘NULL’ and you should find this line: NULL
Directly above it add: null
Save and reboot
Just what i was looking for – thank you
I could kiss you! I opened the silly phtml file and I looked at that sea of black.. I wanted to cry.
By the way, if you are interested, I have been writing a few articles on how to use Dreamweaver (CS4 by now) to work with dynamic applications like Joomla, Drupal and, I hope, Magento.
In short, I do a “view source with” in firefox with the web dev toolbar, save as to a working folder in my local site and I relink the CSS and JS files (in CS4 they actually work in Live View). From then on, working on the CSS and even the PHP files is much easier and faster.
I am still trying to figure out Magento. Not to crazy about the template system. Too many moving parts, to many static blocks for my taste.
Thank you for the tip. Appreciated.
Thanks mate, this was driving me nuts!
Thanks for the tip. I am very pleased that I won’t have to hunt that one down on my own.
Thanks man, now my dw is much more usable
Thank you Coleman! It’s very useful for me.
Anyone know how to assign for a filename that has two periods in it? Not even sure what to call that.
Instead of:
.html
I have files named:
.html.erb
I assume it’s not working because of the period – any clues?
winfileextension=”html,htm,shtml,shtm,stm,tpl,lasso,xhtml,thtml,erb,html.erb”
Chad, Thank you, nice and very easy, tks again…
Awesome, just what I was looking for! I can finally read .inc files without suffering a complete mental breakdown
Thanks a bunch for this writeup. I have many .html files with PHP in them, which is now properly highlighted.
Thanks again!
Thank you so much! This was exactly what I was looking for…
after struggling for a while trying to get something to work in cake’s custom .ctp file extension I realized I needed my php code highlighting back…
You saved my night, now I won’t be so confused when trying to escape my quotes!
Using your method Cake Template Pages or .ctp files now have syntax highlighting. Thanks for posting this!
Thank you! I was able to get it working with .master pages. It was quite a hassle to edit without syntax highlighting.
Dreamweaver has been my personal goto program for years. I truly do not know what I would do without it. There were times when I initially started using the application, and I thought it was way too complicated. Now I fly around it, and it has turned into a great asset in my personal tool box. Anyway thanks for the information.
thanx a bunch, I used this method to go for .less files. give .less css a try guys, it is really awesome… http://lesscss.org/docs.html
Perfect! Thank you.
Thnx a lot Chad.
Thanks Chad.
Chad ROCKS!
Well played.
Thanks! Working great in CS 5.5!