Chapter 3: Templates and Layout
Editing a Template using an External Editor
Problem
You would rather use a text or web page editor to edit a template.
Solution
Link an external file to your template and edit the file.
Discussion
Some users will find it easier to edit the template layouts in a text editor like BBEdit or a web page editor like Adobe Go Live instead of the Movable Type browser interface. You can optionally link a Movable Type template to an external file. This allows you to edit your templates while keeping the copy that is inside Movable Type synchronized with the external file.
In the field labeled "Link this template to a file" on the New/Edit
Template screen, enter either a full path to your external file, or a path
relative to the Local Site Path. For security purposes, the
file extension cannot be .cgi, .pm, .pl, or
.cfg. This is to avoid the potential of overwriting Movable Type
program files and corrupting the system. When you save the template the
files will be linked.
The synchronization process works in both directions. When you load a template for editing, the date of the linked file is checked, and the template is updated if the linked file date is more recent. When you save a template through the Movable Type CMS, the linked file is updated with your changes.
When you create a new template without specifying a template body, and link it to a file that already exists, the contents of that file will be pulled in to the template. If you do specify a template body, however, and the linked file already exists, that linked file will be overwritten with the template body you specified.
For instance, if you would like to maintain your Main Index template with an external editor, you would first set the linked file field to something like index.html.tmpl and click the "Save" action button. You can then edit this file externally. The next time you rebuild, Movable Type will read in the latest version of the linked file index.html.tmpl and use that as the template body. During this process it will also update the copy of the template in the Movable Type database, so that the next time it needs the template it can use the version in the database.
Another added benefit to linking a template to an external file is that you can synchronize templates across multiple weblogs. This is particularly helpful when you have multiple weblogs that require the same layout.
To do this, link all of the source weblog's templates to file. This creates external files of all the template you want to share. Then go into the other weblogs and link their templates to the files created by the first one. When you rebuild those weblogs they will now have the same templates.



