Nuketown

Dreamweaver's Mysterious Template Extension

Posted in by Kenneth Newquist on Wed, 09/22/2004 - 2:00am

For the last few weeks Dreamweaver MX 2004 has been driving me buggy. Despite the fact that I specified in the preferences that all new documents based on my templates should be saved as PHP files, Dreamweaver consistantly insisted on using a .htm file instead.

As the scripts in a PHP file won't execute if the file doesn't have a .php extension, this was a problem. Yeah, the user could give any new files they created a .php extension, but they'd have to remember to do that ... and all of us have our off days.

What I wanted was for .php to always be the default, no matter what. At first I thought that Dreamweaver was reading the doctype declaration in the templates I'd created for the Web site. But after messing around with removing those, Dreamweaver still gave my files a ".htm" extension.

And then, after playing around with the "new document" preferences I saw an entry for "PHP Template", with the extention ".dwt.php". I hadn't chosen it when I'd seen it earlier, because I assumed that it would give all new documents an extention of ".dwt.php", which is not what I wanted.

But it got me to thinking ... maybe if I added a ".php" to all of my templates, Dreamweaver would use that as the extention.

And I was right. That's exactly what Dreamweaver wanted me to do.

Mystery solved.