View Single Post
  #9  
Old 11-08-2002, 01:34 PM
  minorgod's Avatar 
minorgod minorgod is offline
 

X-Adept
  
Join Date: Sep 2002
Location: Arivaca, AZ
Posts: 402
 

Default Adding the smarty template document type to DreamweaverMX

This is the REAL way to make your templates render in DreamweaverMX's design view with the added benefit that the template icons will show up in your file browser as a native DreamweaverMX documents and you'll have no trouble opening them from within DreamweaverMX. You just need to edit a couple of files and create one new one. Here's how:

Open your Dreamweaver MX\Configuration\Strings directory and add the following entries to the end of the "documenttypes.xml" file before the last closing </strings> tag:

Code:
<string id="mmdocumenttypes_64" value="Smarty Template" /> <string id="mmdocumenttypes_65" value="<![CDATA[Smarty Template Document]]>" />

You should make sure to use consecutive numbers in the string id and make sure they don't conflict with previous entries in the event that you've modified this file already. The first entry above is the doctype's title, and the second is the doctype's description. In the CDATA part you can add a longer description if you like.

Next open the Dreamweaver MX\Configuration\DocumentTypes folder and open the MMDocumentTypes.xml file.

Add the following entry to it just before the closing </documenttypes> tag at the end of the file:

Code:
<documenttype id="SmartyTPL" internaltype="HTML" winfileextension="tpl" macfileextension="tpl" file="Default.tpl"> <TITLE> <MMString:loadString id="mmdocumenttypes_64" /> </TITLE> <description> <MMString:loadString id="mmdocumenttypes_65" /> </description> </documenttype>

That will add the actual document type definition to the DreamweaverMX. Make sure that the numbers you use for your loadstring ids correspond to the string id you created in the first step.

Now for your final step, you should create a blank template document called "Default.tpl" which will be the default document that is created when you create a new .tpl document from DreamweaverMX's file menu. You can just leave the document empty, or start it off with a Smarty-style comment line such as:

Code:
{* Smarty Template *}

Or use whatever code you want to be automatically present each time you create a new template from scratch.

Now save this file as:
Dreamweaver MX\Configuration\DocumentTypes\NewDocuments\Defaul t.tpl

Now restart Dreamweaver and you'll notice that all your .tpl files look like native Dreamweaver docs, your templates will render properly as HTML in design view (but be careful that smarty tags don't get converted to HTML equivalents when you do edits), and if you create a new document, you'll have the ability to choose "Smarty Template" as one of the new document types. Pretty cool if you spend much time writing Smarty template code.

You can apply this technique to other file type as well. I recommend doing the same for your .inc file extensions (or just add the .inc extension to your HTML file type definition at the top of the MMDocumentTypes.xml file). If you decide to do that too, then you'll need to perform one final step to get .inc files to render in design view. Open your dreamweaver Edit-->Preferences-->File Types menu and remove the .inc file extension from the box at the top of the window labeled "Open in code view". Any file extensions in this list will only be viewable in code view.

TTFN.
Enjoy.
__________________
www.brettbrewer.com
Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more.
Reply With Quote