Search code examples
phphtmltemplatesdefaultdreamweaver

Changing the default dreamweaver templates


I'm not sure if this is programming-related enough for stack overflow, but anyways...

I want to change the code that is created in dreamweaver when you create a new HTML file or PHP file.

For example, I want to replace the default doctype and HTML tag:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

with this:

<!DOCTYPE html>
<html>

How can I do this?


Solution

  • On Mac OS X, you'll find Dreamweaver's Document Type Declaration configurations at:

    /Applications/Adobe Dreamweaver/Configuration/DocumentTypes
    

    To add a new template for HTML5 documents, open the file MMDocumentTypeDeclarations.xml and add a new element:

    <documenttypedeclaration id="mm_html_5">
        <title>
            <MMString:loadString id="mmdocumenttypedeclarations/mm_html_5" />
        </title>
    
        <doctypedecl>
            <![CDATA[<!DOCTYPE HTML>]]>
        </doctypedecl>
    
        <rootelement>
            <![CDATA[<html></html>]]>
        </rootelement>
    
        <dtdcontext>html</dtdcontext>
        <dtdcontext>html5</dtdcontext>
        <dtdcontext>frameset_frame</dtdcontext>
        <dtdcontext>xslt</dtdcontext>
    </documenttypedeclaration>
    

    When creating new documents, Dreamweaver references MMDocumentTypeDeclarations.xml and matches the <dtdcontext> against the Page Type you selected in the New Document dialog box.

    By modifying this XML file, you don't have to edit any of the templates in:

    /Applications/Adobe Dreamweaver/Configuration/DocumentTypes/NewDocuments
    

    If you're running Dreamweaver CS5+ (version 11), Adobe already includes updated DTDs for HTML5:

    Dreamweaver New Document Dialog Box

    Which creates the following blank document:

    <!DOCTYPE HTML>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Untitled Document</title>
    </head>
    
    <body>
    </body>
    
    </html>
    

    You can change which DOCTYPE is used by default when creating new documents by going into Dreamweaver's preferences:

    Dreamweaver New Document Preferences